Preselect IFC class when adding elements for convenience.

This commit is contained in:
Dion Moult
2025-01-14 14:22:15 +11:00
parent 48f534e7c1
commit 595a3b3f87
2 changed files with 8 additions and 2 deletions
+3 -1
View File
@@ -112,7 +112,9 @@ class LaunchTypeManager(bpy.types.Operator):
row.menu("BIM_MT_type_manager_menu", text="", icon="PREFERENCES")
row = self.layout.row(align=True)
row.operator("bim.launch_add_element", text=f"Create New {AuthoringData.data['ifc_element_type'] or 'Type'}", icon="ADD")
row.operator(
"bim.add_element", text=f"Create New {AuthoringData.data['ifc_element_type'] or 'Type'}", icon="ADD"
).ifc_class = (AuthoringData.data["ifc_element_type"] or "")
if AuthoringData.data["total_types"]:
row = self.layout.row(align=True)
@@ -341,16 +341,20 @@ class AddElement(bpy.types.Operator, tool.Ifc.Operator):
bl_label = "Add Element"
bl_options = {"REGISTER", "UNDO"}
bl_description = "Add an IFC physical product, construction type, and more"
ifc_class: bpy.props.StringProperty(options={"SKIP_SAVE"})
def invoke(self, context, event):
return IfcStore.execute_ifc_operator(self, context, is_invoke=True)
def _invoke(self, context, event):
props = context.scene.BIMRootProperties
# For convenience, preselect OBJ representation template if applicable
if (obj := context.active_object) and obj.type == "MESH":
props = context.scene.BIMRootProperties
props.representation_template = "OBJ"
props.representation_obj = obj
# For convenience, preselect IFC class
if self.ifc_class:
props.ifc_class = self.ifc_class
return context.window_manager.invoke_props_dialog(self)
def _execute(self, context):