Fix #1524. Fixed bug where unlinking copied Blender objects didn't work.

This commit is contained in:
Dion Moult
2021-06-15 13:05:24 +10:00
parent fc05bdf6d6
commit 90cb56220f
16 changed files with 49 additions and 7 deletions
+2 -1
View File
@@ -60,7 +60,8 @@ def active_object_callback():
for obj in bpy.context.selected_objects:
if not obj.BIMObjectProperties.ifc_definition_id:
continue
if IfcStore.id_map[obj.BIMObjectProperties.ifc_definition_id] != obj:
stored_obj = IfcStore.get_element(obj.BIMObjectProperties.ifc_definition_id)
if stored_obj and stored_obj != obj:
bpy.ops.bim.copy_class(obj=obj.name)
+12 -6
View File
@@ -84,13 +84,19 @@ class IfcStore:
except:
pass
if element:
del IfcStore.id_map[element.id()]
else:
del IfcStore.id_map[obj.BIMObjectProperties.ifc_definition_id]
try:
if element:
del IfcStore.id_map[element.id()]
else:
del IfcStore.id_map[obj.BIMObjectProperties.ifc_definition_id]
except:
pass
if element and hasattr(element, "GlobalId"):
del IfcStore.guid_map[element.GlobalId]
try:
if element and hasattr(element, "GlobalId"):
del IfcStore.guid_map[element.GlobalId]
except:
pass
if obj:
obj.BIMObjectProperties.ifc_definition_id = 0
@@ -16,6 +16,8 @@ class BIM_PT_aggregate(Panel):
props = context.active_object.BIMObjectProperties
if not props.ifc_definition_id:
return False
if not IfcStore.get_element(props.ifc_definition_id):
return False
if not IfcStore.get_file().by_id(props.ifc_definition_id).is_a("IfcObjectDefinition"):
return False
if props.ifc_definition_id not in Data.products:
@@ -78,6 +78,8 @@ class BIM_PT_object_attributes(Panel):
@classmethod
def poll(cls, context):
if not IfcStore.get_element(context.active_object.BIMObjectProperties.ifc_definition_id):
return False
return bool(context.active_object.BIMObjectProperties.ifc_definition_id)
def draw(self, context):
@@ -20,6 +20,8 @@ class BIM_PT_boundary(Panel):
props = context.active_object.BIMObjectProperties
if not props.ifc_definition_id:
return False
if not IfcStore.get_element(props.ifc_definition_id):
return False
if IfcStore.get_file().by_id(props.ifc_definition_id).is_a() not in ["IfcSpace", "IfcExternalSpatialElement"]:
return False
return True
@@ -70,6 +70,8 @@ class BIM_PT_classification_references(Panel):
@classmethod
def poll(cls, context):
if not IfcStore.get_element(context.active_object.BIMObjectProperties.ifc_definition_id):
return False
return bool(context.active_object.BIMObjectProperties.ifc_definition_id)
def draw(self, context):
@@ -64,6 +64,8 @@ class BIM_PT_object_constraints(Panel):
@classmethod
def poll(cls, context):
if not IfcStore.get_element(context.active_object.BIMObjectProperties.ifc_definition_id):
return False
return bool(context.active_object.BIMObjectProperties.ifc_definition_id)
def draw(self, context):
@@ -68,6 +68,8 @@ class BIM_PT_object_documents(Panel):
@classmethod
def poll(cls, context):
if not IfcStore.get_element(context.active_object.BIMObjectProperties.ifc_definition_id):
return False
return bool(context.active_object.BIMObjectProperties.ifc_definition_id)
def draw(self, context):
@@ -14,6 +14,8 @@ class BIM_PT_representations(Panel):
@classmethod
def poll(cls, context):
if not IfcStore.get_element(context.active_object.BIMObjectProperties.ifc_definition_id):
return False
return IfcStore.get_file()
def draw(self, context):
@@ -36,6 +36,8 @@ class BIM_PT_object_material(Panel):
props = context.active_object.BIMObjectProperties
if not props.ifc_definition_id:
return False
if not IfcStore.get_element(props.ifc_definition_id):
return False
if not hasattr(IfcStore.get_file().by_id(props.ifc_definition_id), "HasAssociations"):
return False
return True
@@ -101,6 +101,8 @@ class BIM_PT_object_psets(Panel):
props = context.active_object.BIMObjectProperties
if not props.ifc_definition_id:
return False
if not IfcStore.get_element(props.ifc_definition_id):
return False
if props.ifc_definition_id not in Data.products:
Data.load(IfcStore.get_file(), props.ifc_definition_id)
if not Data.products[props.ifc_definition_id]:
@@ -144,6 +146,8 @@ class BIM_PT_object_qtos(Panel):
props = context.active_object.BIMObjectProperties
if not props.ifc_definition_id:
return False
if not IfcStore.get_element(props.ifc_definition_id):
return False
if props.ifc_definition_id not in Data.products:
Data.load(IfcStore.get_file(), props.ifc_definition_id)
if not Data.products[props.ifc_definition_id]:
@@ -25,6 +25,7 @@ class BIM_PT_class(Panel):
row = self.layout.row(align=True)
row.label(text="IFC Element Not Found")
row.operator("bim.unlink_object", icon="UNLINKED", text="")
return
if props.is_reassigning_class:
row = self.layout.row(align=True)
row.operator("bim.reassign_class", icon="CHECKMARK")
@@ -17,6 +17,8 @@ class BIM_PT_spatial(Panel):
oprops = context.active_object.BIMObjectProperties
if not oprops.ifc_definition_id:
return False
if not IfcStore.get_element(oprops.ifc_definition_id):
return False
if oprops.ifc_definition_id not in Data.products:
Data.load(IfcStore.get_file(), oprops.ifc_definition_id)
if not Data.products[oprops.ifc_definition_id]:
@@ -76,6 +76,8 @@ class BIM_PT_structural_boundary_conditions(Panel):
props = context.active_object.BIMObjectProperties
if not props.ifc_definition_id:
return False
if not IfcStore.get_element(props.ifc_definition_id):
return False
if not IfcStore.get_file().by_id(props.ifc_definition_id).is_a("IfcStructuralConnection"):
return False
return True
@@ -106,6 +108,8 @@ class BIM_PT_connected_structural_members(Panel):
props = context.active_object.BIMObjectProperties
if not props.ifc_definition_id:
return False
if not IfcStore.get_element(props.ifc_definition_id):
return False
if not IfcStore.get_file().by_id(props.ifc_definition_id).is_a("IfcStructuralConnection"):
return False
return True
@@ -160,6 +164,8 @@ class BIM_PT_structural_member(Panel):
props = context.active_object.BIMObjectProperties
if not props.ifc_definition_id:
return False
if not IfcStore.get_element(props.ifc_definition_id):
return False
if not IfcStore.get_file().by_id(props.ifc_definition_id).is_a("IfcStructuralMember"):
return False
return True
@@ -198,6 +204,8 @@ class BIM_PT_structural_connection(Panel):
props = context.active_object.BIMObjectProperties
if not props.ifc_definition_id:
return False
if not IfcStore.get_element(props.ifc_definition_id):
return False
if not IfcStore.get_file().by_id(props.ifc_definition_id).is_a("IfcStructuralConnection"):
return False
return True
@@ -15,6 +15,8 @@ class BIM_PT_type(Panel):
props = context.active_object.BIMObjectProperties
if not props.ifc_definition_id:
return False
if not IfcStore.get_element(props.ifc_definition_id):
return False
if props.ifc_definition_id not in Data.products:
Data.load(IfcStore.get_file(), props.ifc_definition_id)
if not Data.products[props.ifc_definition_id]:
@@ -14,6 +14,8 @@ class BIM_PT_voids(Panel):
@classmethod
def poll(cls, context):
if not IfcStore.get_element(context.active_object.BIMObjectProperties.ifc_definition_id):
return False
return IfcStore.get_file()
def draw(self, context):