mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-25 17:57:02 +00:00
fix #4431: prompt for name, when creating aggregate
This commit is contained in:
@@ -132,6 +132,7 @@ class BIM_OT_add_aggregate(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
bl_options = {"REGISTER", "UNDO"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
obj: bpy.props.StringProperty()
|
obj: bpy.props.StringProperty()
|
||||||
ifc_class: bpy.props.StringProperty(name="IFC Class", default="IfcElementAssembly")
|
ifc_class: bpy.props.StringProperty(name="IFC Class", default="IfcElementAssembly")
|
||||||
|
aggregate_name: bpy.props.StringProperty(name="Name", default="Default_Name")
|
||||||
|
|
||||||
def invoke(self, context, event):
|
def invoke(self, context, event):
|
||||||
return context.window_manager.invoke_props_dialog(self)
|
return context.window_manager.invoke_props_dialog(self)
|
||||||
@@ -139,13 +140,15 @@ class BIM_OT_add_aggregate(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
row = self.layout
|
row = self.layout
|
||||||
row.prop(self, "ifc_class")
|
row.prop(self, "ifc_class")
|
||||||
|
row = self.layout
|
||||||
|
row.prop(self, "aggregate_name")
|
||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
try:
|
try:
|
||||||
ifc_class = tool.Ifc.schema().declaration_by_name(self.ifc_class).name()
|
ifc_class = tool.Ifc.schema().declaration_by_name(self.ifc_class).name()
|
||||||
except:
|
except:
|
||||||
return
|
return
|
||||||
aggregate = self.create_aggregate(context, ifc_class)
|
aggregate = self.create_aggregate(context, ifc_class, self.aggregate_name)
|
||||||
|
|
||||||
for obj in context.selected_objects:
|
for obj in context.selected_objects:
|
||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
@@ -173,8 +176,8 @@ class BIM_OT_add_aggregate(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
)
|
)
|
||||||
core.assign_object(tool.Ifc, tool.Aggregate, tool.Collector, relating_obj=aggregate, related_obj=obj)
|
core.assign_object(tool.Ifc, tool.Aggregate, tool.Collector, relating_obj=aggregate, related_obj=obj)
|
||||||
|
|
||||||
def create_aggregate(self, context, ifc_class):
|
def create_aggregate(self, context, ifc_class, aggregate_name):
|
||||||
aggregate = bpy.data.objects.new("Assembly", None)
|
aggregate = bpy.data.objects.new(aggregate_name, None)
|
||||||
aggregate.location = context.scene.cursor.location
|
aggregate.location = context.scene.cursor.location
|
||||||
bpy.ops.bim.assign_class(obj=aggregate.name, ifc_class=ifc_class)
|
bpy.ops.bim.assign_class(obj=aggregate.name, ifc_class=ifc_class)
|
||||||
return aggregate
|
return aggregate
|
||||||
|
|||||||
Reference in New Issue
Block a user