mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
Prefill class / product type if using a particular BIM tool for convenience, and hide fields.
This commit is contained in:
@@ -112,9 +112,12 @@ class LaunchTypeManager(bpy.types.Operator):
|
||||
row.menu("BIM_MT_type_manager_menu", text="", icon="PREFERENCES")
|
||||
|
||||
row = self.layout.row(align=True)
|
||||
row.operator(
|
||||
op = 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 "")
|
||||
)
|
||||
op.is_specific_tool = bool(AuthoringData.data["ifc_element_type"])
|
||||
op.ifc_product = "IfcElementType"
|
||||
op.ifc_class = AuthoringData.data["ifc_element_type"] or props.ifc_class or ""
|
||||
|
||||
if AuthoringData.data["total_types"]:
|
||||
row = self.layout.row(align=True)
|
||||
|
||||
@@ -392,10 +392,12 @@ class CreateObjectUI:
|
||||
|
||||
row = box.row(align=True)
|
||||
row.alignment = "CENTER"
|
||||
row.operator(
|
||||
"bim.launch_add_element",
|
||||
text=f"Create New {AuthoringData.data['ifc_element_type']}",
|
||||
op = row.operator(
|
||||
"bim.add_element", text=f"Create New {AuthoringData.data['ifc_element_type'] or 'Type'}", icon="ADD"
|
||||
)
|
||||
op.is_specific_tool = bool(AuthoringData.data["ifc_element_type"])
|
||||
op.ifc_product = "IfcElementType"
|
||||
op.ifc_class = AuthoringData.data["ifc_element_type"] or props.ifc_class or ""
|
||||
|
||||
row = box.row(align=True)
|
||||
|
||||
|
||||
@@ -341,6 +341,8 @@ 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"
|
||||
is_specific_tool: bpy.props.BoolProperty(default=False, options={"SKIP_SAVE"})
|
||||
ifc_product: bpy.props.StringProperty(options={"SKIP_SAVE"})
|
||||
ifc_class: bpy.props.StringProperty(options={"SKIP_SAVE"})
|
||||
|
||||
def invoke(self, context, event):
|
||||
@@ -353,6 +355,8 @@ class AddElement(bpy.types.Operator, tool.Ifc.Operator):
|
||||
props.representation_template = "OBJ"
|
||||
props.representation_obj = obj
|
||||
# For convenience, preselect IFC class
|
||||
if self.ifc_product:
|
||||
props.ifc_product = self.ifc_product
|
||||
if self.ifc_class:
|
||||
props.ifc_class = self.ifc_class
|
||||
return context.window_manager.invoke_props_dialog(self)
|
||||
@@ -562,8 +566,9 @@ class AddElement(bpy.types.Operator, tool.Ifc.Operator):
|
||||
row.prop(props, "name")
|
||||
row = self.layout.row()
|
||||
row.prop(props, "description")
|
||||
prop_with_search(self.layout, props, "ifc_product", text="Definition", should_click_ok=True)
|
||||
prop_with_search(self.layout, props, "ifc_class", should_click_ok=True)
|
||||
if not self.is_specific_tool:
|
||||
prop_with_search(self.layout, props, "ifc_product", text="Definition", should_click_ok=True)
|
||||
prop_with_search(self.layout, props, "ifc_class", should_click_ok=True)
|
||||
ifc_predefined_types = root_prop.get_ifc_predefined_types(context.scene.BIMRootProperties, context)
|
||||
if ifc_predefined_types:
|
||||
prop_with_search(self.layout, props, "ifc_predefined_type", should_click_ok=True)
|
||||
|
||||
Reference in New Issue
Block a user