mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 02:02:22 +00:00
Improve logic for https://github.com/IfcOpenShell/IfcOpenShell/commit/bced62bd5c6615ec1ff8c3a6af3334e469e5f9fa
This commit is contained in:
@@ -48,7 +48,7 @@ def get_representation_template(self, context):
|
||||
|
||||
|
||||
def refresh_classes(self, context):
|
||||
old_class = context.scene.BIMRootProperties.ifc_class.split("Type")[0]
|
||||
old_class = context.scene.BIMRootProperties.ifc_class
|
||||
old_predefined_type = (
|
||||
context.scene.BIMRootProperties.ifc_predefined_type if get_ifc_predefined_types(self, context) else ""
|
||||
)
|
||||
@@ -58,13 +58,13 @@ def refresh_classes(self, context):
|
||||
IfcClassData.load()
|
||||
|
||||
# When switching between ElementType and Element, keep the same class and predefined type if possible
|
||||
if context.scene.BIMRootProperties.ifc_product == "IfcElementType":
|
||||
ifc_class = old_class + "Type"
|
||||
elif context.scene.BIMRootProperties.ifc_product == "IfcElement":
|
||||
ifc_class = old_class
|
||||
if context.scene.BIMRootProperties.ifc_product == "IfcElement":
|
||||
ifc_class = next(iter(ifcopenshell.util.type.get_applicable_entities(old_class)), None)
|
||||
elif context.scene.BIMRootProperties.ifc_product == "IfcElementType":
|
||||
ifc_class = next(iter(ifcopenshell.util.type.get_applicable_types(old_class)), None)
|
||||
else:
|
||||
return
|
||||
if ifc_class in [e[0] for e in get_ifc_classes(self, context)]:
|
||||
if ifc_class:
|
||||
context.scene.BIMRootProperties.ifc_class = ifc_class
|
||||
if old_predefined_type:
|
||||
context.scene.BIMRootProperties.ifc_predefined_type = old_predefined_type
|
||||
|
||||
Reference in New Issue
Block a user