Fix issue assigning bsdd classification in ifc2x3 #5073

This commit is contained in:
Andrej730
2024-07-24 17:57:21 +05:00
parent 075a0c79e2
commit 7edd1225c0
@@ -117,17 +117,20 @@ class AddClassificationFromBSDD(bpy.types.Operator, tool.Ifc.Operator):
bl_options = {"REGISTER", "UNDO"}
def _execute(self, context):
is_ifc2x3 = tool.Ifc.get_schema() == "IFC2X3"
props = context.scene.BIMBSDDProperties
domain = [d for d in props.domains if d.name == props.active_domain][0]
for element in tool.Ifc.get().by_type("IfcClassification"):
if element.Name == props.active_domain or element.Location == domain.uri:
if element.Name == props.active_domain or (not is_ifc2x3 and element.Location == domain.uri):
return
classification = ifcopenshell.api.run(
"classification.add_classification", tool.Ifc.get(), classification=props.active_domain
)
classification.Source = domain.organization_name_owner
classification.Location = domain.uri
classification.Edition = domain.version
if not is_ifc2x3:
classification.Location = domain.uri
class EnableAddingManualClassification(bpy.types.Operator):
@@ -397,6 +400,8 @@ class AddClassificationReferenceFromBSDD(bpy.types.Operator, tool.Ifc.Operator):
obj_type: bpy.props.StringProperty()
def _execute(self, context):
is_ifc2x3 = tool.Ifc.get_schema() == "IFC2X3"
if self.obj_type == "Object":
if context.selected_objects:
objects = [o.name for o in context.selected_objects]
@@ -413,7 +418,7 @@ class AddClassificationReferenceFromBSDD(bpy.types.Operator, tool.Ifc.Operator):
for element in tool.Ifc.get().by_type("IfcClassification"):
if (
element.Name == bsdd_classification.domain_name
or element.Location == bsdd_classification.domain_namespace_uri
or (not is_ifc2x3 and element.Location == bsdd_classification.domain_namespace_uri)
):
classification = element
break
@@ -422,7 +427,8 @@ class AddClassificationReferenceFromBSDD(bpy.types.Operator, tool.Ifc.Operator):
classification = ifcopenshell.api.run(
"classification.add_classification", tool.Ifc.get(), classification=bsdd_classification.domain_name
)
classification.Location = bsdd_classification.domain_namespace_uri
if not is_ifc2x3:
classification.Location = bsdd_classification.domain_namespace_uri
for obj in objects:
ifc_definition_id = tool.Blender.get_obj_ifc_definition_id(obj, self.obj_type, context)