unresolve_type_representation - typing and small optimization

This commit is contained in:
Andrej730
2024-06-21 12:31:43 +05:00
parent a594a6cfe2
commit 5731c4036a
+10 -1
View File
@@ -686,17 +686,26 @@ class Geometry(blenderbim.core.tool.Geometry):
return representation
@classmethod
def unresolve_type_representation(cls, representation, occurence):
def unresolve_type_representation(
cls, representation: ifcopenshell.entity_instance, occurence: ifcopenshell.entity_instance
) -> ifcopenshell.entity_instance:
if not ifcopenshell.util.element.get_type(occurence):
return representation
if representation.RepresentationType == "MappedRepresentation":
return representation
context = representation.ContextOfItems
for mapped_representation in occurence.Representation.Representations:
if mapped_representation.ContextOfItems != context:
continue
if cls.resolve_mapped_representation(mapped_representation) == representation:
return mapped_representation
raise Exception(
f"Couldn't find any representation matching type representation {representation} in occurrence {occurence}."
)
@classmethod
def run_geometry_update_representation(cls, obj=None):
bpy.ops.bim.update_representation(obj=obj.name, ifc_representation_class="")