mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 02:07:36 +00:00
unresolve_type_representation - typing and small optimization
This commit is contained in:
@@ -686,17 +686,26 @@ class Geometry(blenderbim.core.tool.Geometry):
|
|||||||
return representation
|
return representation
|
||||||
|
|
||||||
@classmethod
|
@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):
|
if not ifcopenshell.util.element.get_type(occurence):
|
||||||
return representation
|
return representation
|
||||||
|
|
||||||
if representation.RepresentationType == "MappedRepresentation":
|
if representation.RepresentationType == "MappedRepresentation":
|
||||||
return representation
|
return representation
|
||||||
|
|
||||||
|
context = representation.ContextOfItems
|
||||||
for mapped_representation in occurence.Representation.Representations:
|
for mapped_representation in occurence.Representation.Representations:
|
||||||
|
if mapped_representation.ContextOfItems != context:
|
||||||
|
continue
|
||||||
if cls.resolve_mapped_representation(mapped_representation) == representation:
|
if cls.resolve_mapped_representation(mapped_representation) == representation:
|
||||||
return mapped_representation
|
return mapped_representation
|
||||||
|
|
||||||
|
raise Exception(
|
||||||
|
f"Couldn't find any representation matching type representation {representation} in occurrence {occurence}."
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run_geometry_update_representation(cls, obj=None):
|
def run_geometry_update_representation(cls, obj=None):
|
||||||
bpy.ops.bim.update_representation(obj=obj.name, ifc_representation_class="")
|
bpy.ops.bim.update_representation(obj=obj.name, ifc_representation_class="")
|
||||||
|
|||||||
Reference in New Issue
Block a user