bim.convert_to_blender to avoid types without mesh properties

This commit is contained in:
Andrej730
2024-08-21 14:50:04 +05:00
parent ef04402ed8
commit 12a7b8a79e
2 changed files with 22 additions and 2 deletions
@@ -92,8 +92,9 @@ class ConvertToBlender(bpy.types.Operator):
for obj in bpy.data.objects:
if obj.type in {"MESH", "EMPTY"}:
tool.Ifc.unlink(obj=obj)
if obj.data:
obj.data.BIMMeshProperties.ifc_definition_id = 0
data = obj.data
if tool.Geometry.has_mesh_properties(data):
data.BIMMeshProperties.ifc_definition_id = 0
for material in bpy.data.materials:
tool.Ifc.unlink(obj=material)
context.scene.BIMProperties.ifc_file = ""
+19
View File
@@ -661,6 +661,25 @@ class Geometry(bonsai.core.tool.Geometry):
return False
return isinstance(data, supported_types)
@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,
]
]:
supported_types = (
bpy.types.Mesh,
bpy.types.Curve,
bpy.types.Camera,
bpy.types.PointLight,
)
if not data:
return False
return isinstance(data, supported_types)
@classmethod
def is_edited(cls, obj: bpy.types.Object) -> bool:
return not all([tool.Cad.is_x(o, 1.0) for o in obj.scale]) or obj in IfcStore.edited_objs