bim.unlink_object to skip popup if element is not found

If element is not found then it should always use `should_delete == False`, so we can just hide the popup in that case so users won't get confused about what should they choose.
This commit is contained in:
Andrej730
2024-06-25 12:13:03 +05:00
parent c5262274eb
commit a65c6b6d3f
2 changed files with 6 additions and 1 deletions
@@ -217,6 +217,7 @@ class UnlinkObject(bpy.types.Operator):
bl_options = {"REGISTER", "UNDO"}
obj: bpy.props.StringProperty(name="Object Name")
should_delete: bpy.props.BoolProperty(name="Delete IFC Element", default=True)
skip_invoke: bpy.props.BoolProperty(default=False, options={"SKIP_SAVE"})
def execute(self, context):
return IfcStore.execute_ifc_operator(self, context)
@@ -286,6 +287,8 @@ class UnlinkObject(bpy.types.Operator):
row.prop(self, "should_delete")
def invoke(self, context, event):
if self.skip_invoke:
return self.execute(context)
return context.window_manager.invoke_props_dialog(self)
@@ -47,7 +47,9 @@ class BIM_PT_class(Panel):
if not IfcClassData.data["has_entity"]:
row = self.layout.row(align=True)
row.label(text="IFC Element Not Found")
row.operator("bim.unlink_object", icon="UNLINKED", text="")
op = row.operator("bim.unlink_object", icon="UNLINKED", text="")
op.should_delete = False
op.skip_invoke = True
return
if props.is_reassigning_class:
row = self.layout.row(align=True)