Fix #1361. You can now unlink objects and styles of elements that you've lost the IFC of to recover them.

This commit is contained in:
Dion Moult
2021-03-09 12:50:50 +11:00
parent 310d13ac75
commit aceb2140ad
5 changed files with 27 additions and 5 deletions
@@ -215,6 +215,8 @@ class UnlinkObject(bpy.types.Operator):
for obj in objects:
if obj.BIMObjectProperties.ifc_definition_id:
obj.BIMObjectProperties.ifc_definition_id = 0
if "Ifc" in obj.name and "/" in obj.name:
obj.name = "/".join(obj.name.split("/")[1:])
return {"FINISHED"}
@@ -19,7 +19,12 @@ class BIM_PT_class(Panel):
props = context.active_object.BIMObjectProperties
if props.ifc_definition_id:
if props.ifc_definition_id not in Data.products:
Data.load(props.ifc_definition_id)
try:
Data.load(props.ifc_definition_id)
except:
row = self.layout.row(align=True)
row.label(text="IFC Element Not Found")
row.operator("bim.unlink_object", icon="UNLINKED", text="")
if props.is_reassigning_class:
row = self.layout.row(align=True)
row.operator("bim.reassign_class", icon="CHECKMARK")
@@ -35,7 +40,7 @@ class BIM_PT_class(Panel):
row = self.layout.row(align=True)
row.label(text=name)
row.operator("bim.copy_class", icon="DUPLICATE", text="").obj = context.active_object.name
row.operator("bim.unlink_object", icon="UNLINKED", text="").obj = context.active_object.name
row.operator("bim.unlink_object", icon="UNLINKED", text="")
row.operator("bim.enable_reassign_class", icon="GREASEPENCIL", text="")
row.operator("bim.unassign_class", icon="X", text="").obj = context.active_object.name
else:
@@ -4,6 +4,7 @@ from . import ui, operator
classes = (
operator.AddStyle,
operator.EditStyle,
operator.UnlinkStyle,
ui.BIM_PT_style,
)
@@ -3,8 +3,6 @@ import blenderbim.bim.module.style.add_style as add_style
import blenderbim.bim.module.style.edit_style as edit_style
from blenderbim.bim.ifc import IfcStore
# from blenderbim.bim.module.spatial.data import Data
def get_colour_settings(material):
transparency = material.diffuse_color[3]
@@ -48,3 +46,17 @@ class AddStyle(bpy.types.Operator):
style = add_style.Usecase(self.file, settings).execute()
material.BIMMaterialProperties.ifc_style_id = int(style.id())
return {"FINISHED"}
class UnlinkStyle(bpy.types.Operator):
bl_idname = "bim.unlink_style"
bl_label = "Unlink Style"
material: bpy.props.StringProperty()
def execute(self, context):
self.file = IfcStore.get_file()
material = bpy.data.materials.get(self.material)
material.BIMMaterialProperties.ifc_style_id = 0
if "Ifc" in material.name and "/" in material.name:
material.name = "/".join(material.name.split("/")[1:])
return {"FINISHED"}
@@ -19,8 +19,10 @@ class BIM_PT_style(Panel):
def draw(self, context):
props = context.active_object.active_material.BIMMaterialProperties
row = self.layout.row()
row = self.layout.row(align=True)
if props.ifc_style_id:
row.operator("bim.edit_style", icon="GREASEPENCIL")
op = row.operator("bim.unlink_style", icon="UNLINKED", text="")
op.material = context.active_object.active_material.name
else:
row.operator("bim.add_style", icon="ADD")