This commit is contained in:
Andrej730
2024-08-21 18:15:46 +05:00
parent 8534b6e154
commit a0792a4b93
6 changed files with 26 additions and 12 deletions
+4 -1
View File
@@ -16,6 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
from __future__ import annotations
import os
import bpy
import uuid
@@ -228,7 +229,9 @@ class IfcStore:
IfcStore.commit_link_element(data)
@staticmethod
def link_element(element: ifcopenshell.entity_instance, obj: IFC_CONNECTED_TYPE) -> None:
def link_element(
element: ifcopenshell.entity_instance, obj: Union[IFC_CONNECTED_TYPE, tool.Geometry.TYPES_WITH_MESH_PROPERTIES]
) -> None:
# Please use tool.Ifc.link() instead of this method. We want to
# refactor this class and deprecate usage of IfcStore in favour of
# tools.
+3 -1
View File
@@ -785,7 +785,9 @@ class IfcImporter:
self.set_matrix_world(obj, tool.Loader.apply_blender_offset_to_matrix_world(obj, placement_matrix))
self.link_element(product, obj)
def get_pointcloud_representation(self, product):
def get_pointcloud_representation(
self, product: ifcopenshell.entity_instance
) -> Union[ifcopenshell.entity_instance, None]:
if hasattr(product, "Representation") and hasattr(product.Representation, "Representations"):
representations = product.Representation.Representations
elif hasattr(product, "RepresentationMaps") and hasattr(product.RepresentationMaps, "RepresentationMaps"):
+1
View File
@@ -40,6 +40,7 @@ class Collector(bonsai.core.tool.Collector):
users_collection.objects.unlink(obj)
element = tool.Ifc.get_entity(obj)
assert element
if element.is_a("IfcGridAxis"):
element = (element.PartOfU or element.PartOfV or element.PartOfW)[0]
+8 -8
View File
@@ -663,15 +663,15 @@ class Geometry(bonsai.core.tool.Geometry):
return False
return isinstance(data, supported_types)
TYPES_WITH_MESH_PROPERTIES = Union[
bpy.types.Mesh,
bpy.types.Curve,
bpy.types.Camera,
bpy.types.PointLight,
]
@classmethod
def has_mesh_properties(cls, data: Union[bpy.types.ID, None]) -> TypeIs[
Union[
bpy.types.Mesh,
bpy.types.Curve,
bpy.types.Camera,
bpy.types.PointLight,
]
]:
def has_mesh_properties(cls, data: Union[bpy.types.ID, None]) -> TypeIs[TYPES_WITH_MESH_PROPERTIES]:
supported_types = (
bpy.types.Mesh,
bpy.types.Curve,
+5 -1
View File
@@ -175,7 +175,11 @@ class Ifc(bonsai.core.tool.Ifc):
bonsai.bim.handler.subscribe_to(obj, "name", bonsai.bim.handler.name_callback)
@classmethod
def link(cls, element: ifcopenshell.entity_instance, obj: IFC_CONNECTED_TYPE) -> None:
def link(
cls,
element: ifcopenshell.entity_instance,
obj: Union[IFC_CONNECTED_TYPE, tool.Geometry.TYPES_WITH_MESH_PROPERTIES],
) -> None:
IfcStore.link_element(element, obj)
@classmethod
+5 -1
View File
@@ -98,7 +98,11 @@ class Loader(bonsai.core.tool.Loader):
return "{}/{}".format(element.is_a(), getattr(element, "Name", "None"))
@classmethod
def link_mesh(cls, shape, mesh: OBJECT_DATA_TYPE) -> None:
def link_mesh(
cls,
shape: Union[ifcopenshell.geom.ShapeElementType, ifcopenshell.geom.ShapeType],
mesh: tool.Geometry.TYPES_WITH_MESH_PROPERTIES,
) -> None:
geometry = shape.geometry if hasattr(shape, "geometry") else shape
if "-" in geometry.id:
mesh.BIMMeshProperties.ifc_definition_id = int(geometry.id.split("-")[0])