From 7fdfdbf8b4dc166351dc09bbdd09db8a30012584 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Wed, 15 Jan 2025 20:57:19 +1100 Subject: [PATCH] Fix #5971. You can now specify a name and description when adding objects. Clean naming and description is critical! --- src/bonsai/bonsai/bim/module/root/operator.py | 6 ++++++ src/bonsai/bonsai/bim/module/root/prop.py | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/bonsai/bonsai/bim/module/root/operator.py b/src/bonsai/bonsai/bim/module/root/operator.py index 6213fcc4a7..b2436be1f8 100644 --- a/src/bonsai/bonsai/bim/module/root/operator.py +++ b/src/bonsai/bonsai/bim/module/root/operator.py @@ -384,6 +384,7 @@ class AddElement(bpy.types.Operator, tool.Ifc.Operator): mesh = bpy.data.meshes.new("Mesh") obj = bpy.data.objects.new(props.ifc_class[3:], mesh) + obj.name = props.name or "Unnamed" obj.location = bpy.context.scene.cursor.location element = core.assign_class( tool.Ifc, @@ -394,6 +395,7 @@ class AddElement(bpy.types.Operator, tool.Ifc.Operator): predefined_type=predefined_type, should_add_representation=False, ) + element.Description = props.description or None if representation_template == "EMTPY" or not ifc_context: pass @@ -556,6 +558,10 @@ class AddElement(bpy.types.Operator, tool.Ifc.Operator): props = context.scene.BIMRootProperties self.layout.use_property_split = True self.layout.use_property_decorate = False + row = self.layout.row() + 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) ifc_predefined_types = root_prop.get_ifc_predefined_types(context.scene.BIMRootProperties, context) diff --git a/src/bonsai/bonsai/bim/module/root/prop.py b/src/bonsai/bonsai/bim/module/root/prop.py index 7445b53d8f..9d849d7235 100644 --- a/src/bonsai/bonsai/bim/module/root/prop.py +++ b/src/bonsai/bonsai/bim/module/root/prop.py @@ -127,6 +127,8 @@ def poll_representation_obj(self, obj): class BIMRootProperties(PropertyGroup): contexts: EnumProperty(items=get_contexts, name="Contexts", options=set()) + name: StringProperty(name="Name") + description: StringProperty(name="Description") ifc_product: EnumProperty(items=get_ifc_products, name="Products", update=refresh_classes) ifc_class: EnumProperty(items=get_ifc_classes, name="Class", update=refresh_predefined_types) ifc_predefined_type: EnumProperty(items=get_ifc_predefined_types, name="Predefined Type", default=None)