mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-10 14:07:43 +00:00
when bpy.ops.bim.object_duplicate_move_linked_aggregate is called from the panel, the new objects are placed based on the 3d cursor position
This commit is contained in:
@@ -145,6 +145,7 @@ class BIM_PT_linked_aggregate(Panel):
|
|||||||
else:
|
else:
|
||||||
row.label(text=f"{Number_Linked_Aggregates} Linked Aggregates")
|
row.label(text=f"{Number_Linked_Aggregates} Linked Aggregates")
|
||||||
op = row.operator("bim.object_duplicate_move_linked_aggregate", text="", icon="DUPLICATE")
|
op = row.operator("bim.object_duplicate_move_linked_aggregate", text="", icon="DUPLICATE")
|
||||||
|
op.location_from_3d_cursor = True
|
||||||
if type(Number_Linked_Aggregates) is int:
|
if type(Number_Linked_Aggregates) is int:
|
||||||
if Number_Linked_Aggregates > 0:
|
if Number_Linked_Aggregates > 0:
|
||||||
op = row.operator("bim.select_linked_aggregates", text="", icon="OUTLINER_DATA_POINTCLOUD")
|
op = row.operator("bim.select_linked_aggregates", text="", icon="OUTLINER_DATA_POINTCLOUD")
|
||||||
|
|||||||
@@ -947,6 +947,7 @@ class DuplicateMoveLinkedAggregate(bpy.types.Operator):
|
|||||||
bl_label = "IFC Duplicate Linked Aggregate"
|
bl_label = "IFC Duplicate Linked Aggregate"
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
is_interactive: bpy.props.BoolProperty(name="Is Interactive", default=True)
|
is_interactive: bpy.props.BoolProperty(name="Is Interactive", default=True)
|
||||||
|
location_from_3d_cursor: bpy.props.BoolProperty(name="Position Duplicate Based on 3d cursor", default=False)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
@@ -1074,6 +1075,18 @@ class DuplicateMoveLinkedAggregate(bpy.types.Operator):
|
|||||||
]
|
]
|
||||||
tool.Ifc.run("group.assign_group", group=linked_aggregate_group[0], products=new)
|
tool.Ifc.run("group.assign_group", group=linked_aggregate_group[0], products=new)
|
||||||
|
|
||||||
|
def get_location_from_3d_cursor(old_to_new):
|
||||||
|
for new in old_to_new.values():
|
||||||
|
aggregate = ifcopenshell.util.element.get_aggregate(new[0])
|
||||||
|
if aggregate:
|
||||||
|
base_obj = tool.Ifc.get_object(aggregate)
|
||||||
|
base_obj_location = base_obj.location.copy()
|
||||||
|
break
|
||||||
|
|
||||||
|
for new in old_to_new.values():
|
||||||
|
new_obj = tool.Ifc.get_object(new[0])
|
||||||
|
location_diff = new_obj.location - base_obj_location
|
||||||
|
new_obj.location = context.scene.cursor.location + location_diff
|
||||||
|
|
||||||
if len(context.selected_objects) != 1:
|
if len(context.selected_objects) != 1:
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
@@ -1101,6 +1114,9 @@ class DuplicateMoveLinkedAggregate(bpy.types.Operator):
|
|||||||
|
|
||||||
custom_incremental_naming_for_element_assembly(old_to_new)
|
custom_incremental_naming_for_element_assembly(old_to_new)
|
||||||
|
|
||||||
|
if self.location_from_3d_cursor:
|
||||||
|
get_location_from_3d_cursor(old_to_new)
|
||||||
|
|
||||||
blenderbim.bim.handler.refresh_ui_data()
|
blenderbim.bim.handler.refresh_ui_data()
|
||||||
|
|
||||||
return old_to_new
|
return old_to_new
|
||||||
|
|||||||
Reference in New Issue
Block a user