mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 22:50:21 +00:00
typing
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
import os
|
import os
|
||||||
import bpy
|
import bpy
|
||||||
import uuid
|
import uuid
|
||||||
@@ -228,7 +229,9 @@ class IfcStore:
|
|||||||
IfcStore.commit_link_element(data)
|
IfcStore.commit_link_element(data)
|
||||||
|
|
||||||
@staticmethod
|
@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
|
# Please use tool.Ifc.link() instead of this method. We want to
|
||||||
# refactor this class and deprecate usage of IfcStore in favour of
|
# refactor this class and deprecate usage of IfcStore in favour of
|
||||||
# tools.
|
# tools.
|
||||||
|
|||||||
@@ -785,7 +785,9 @@ class IfcImporter:
|
|||||||
self.set_matrix_world(obj, tool.Loader.apply_blender_offset_to_matrix_world(obj, placement_matrix))
|
self.set_matrix_world(obj, tool.Loader.apply_blender_offset_to_matrix_world(obj, placement_matrix))
|
||||||
self.link_element(product, obj)
|
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"):
|
if hasattr(product, "Representation") and hasattr(product.Representation, "Representations"):
|
||||||
representations = product.Representation.Representations
|
representations = product.Representation.Representations
|
||||||
elif hasattr(product, "RepresentationMaps") and hasattr(product.RepresentationMaps, "RepresentationMaps"):
|
elif hasattr(product, "RepresentationMaps") and hasattr(product.RepresentationMaps, "RepresentationMaps"):
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ class Collector(bonsai.core.tool.Collector):
|
|||||||
users_collection.objects.unlink(obj)
|
users_collection.objects.unlink(obj)
|
||||||
|
|
||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
|
assert element
|
||||||
|
|
||||||
if element.is_a("IfcGridAxis"):
|
if element.is_a("IfcGridAxis"):
|
||||||
element = (element.PartOfU or element.PartOfV or element.PartOfW)[0]
|
element = (element.PartOfU or element.PartOfV or element.PartOfW)[0]
|
||||||
|
|||||||
@@ -663,15 +663,15 @@ class Geometry(bonsai.core.tool.Geometry):
|
|||||||
return False
|
return False
|
||||||
return isinstance(data, supported_types)
|
return isinstance(data, supported_types)
|
||||||
|
|
||||||
|
TYPES_WITH_MESH_PROPERTIES = Union[
|
||||||
|
bpy.types.Mesh,
|
||||||
|
bpy.types.Curve,
|
||||||
|
bpy.types.Camera,
|
||||||
|
bpy.types.PointLight,
|
||||||
|
]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def has_mesh_properties(cls, data: Union[bpy.types.ID, None]) -> TypeIs[
|
def has_mesh_properties(cls, data: Union[bpy.types.ID, None]) -> TypeIs[TYPES_WITH_MESH_PROPERTIES]:
|
||||||
Union[
|
|
||||||
bpy.types.Mesh,
|
|
||||||
bpy.types.Curve,
|
|
||||||
bpy.types.Camera,
|
|
||||||
bpy.types.PointLight,
|
|
||||||
]
|
|
||||||
]:
|
|
||||||
supported_types = (
|
supported_types = (
|
||||||
bpy.types.Mesh,
|
bpy.types.Mesh,
|
||||||
bpy.types.Curve,
|
bpy.types.Curve,
|
||||||
|
|||||||
@@ -175,7 +175,11 @@ class Ifc(bonsai.core.tool.Ifc):
|
|||||||
bonsai.bim.handler.subscribe_to(obj, "name", bonsai.bim.handler.name_callback)
|
bonsai.bim.handler.subscribe_to(obj, "name", bonsai.bim.handler.name_callback)
|
||||||
|
|
||||||
@classmethod
|
@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)
|
IfcStore.link_element(element, obj)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
@@ -98,7 +98,11 @@ class Loader(bonsai.core.tool.Loader):
|
|||||||
return "{}/{}".format(element.is_a(), getattr(element, "Name", "None"))
|
return "{}/{}".format(element.is_a(), getattr(element, "Name", "None"))
|
||||||
|
|
||||||
@classmethod
|
@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
|
geometry = shape.geometry if hasattr(shape, "geometry") else shape
|
||||||
if "-" in geometry.id:
|
if "-" in geometry.id:
|
||||||
mesh.BIMMeshProperties.ifc_definition_id = int(geometry.id.split("-")[0])
|
mesh.BIMMeshProperties.ifc_definition_id = int(geometry.id.split("-")[0])
|
||||||
|
|||||||
Reference in New Issue
Block a user