You can now select only the aggregate or the aggregate and all its part using the interface

This commit is contained in:
Gorgious56
2024-03-26 08:33:18 +01:00
parent bb6be4d52d
commit 4dda7e84a0
2 changed files with 31 additions and 11 deletions
@@ -96,7 +96,7 @@ class BIM_OT_aggregate_unassign_object(bpy.types.Operator, Operator):
) )
# Removes Pset related to Linked Aggregates # Removes Pset related to Linked Aggregates
pset = ifcopenshell.util.element.get_pset(element, 'BBIM_Linked_Aggregate') pset = ifcopenshell.util.element.get_pset(element, "BBIM_Linked_Aggregate")
if pset: if pset:
pset = tool.Ifc.get().by_id(pset["id"]) pset = tool.Ifc.get().by_id(pset["id"])
ifcopenshell.api.run("pset.remove_pset", tool.Ifc.get(), pset=pset) ifcopenshell.api.run("pset.remove_pset", tool.Ifc.get(), pset=pset)
@@ -206,15 +206,29 @@ class BIM_OT_select_aggregate(bpy.types.Operator):
bl_label = "Select Aggregate" bl_label = "Select Aggregate"
bl_options = {"REGISTER", "UNDO"} bl_options = {"REGISTER", "UNDO"}
obj: bpy.props.StringProperty() obj: bpy.props.StringProperty()
select_parts: bpy.props.BoolProperty(default=False)
@classmethod
def description(cls, context, properties):
if properties.select_parts:
return "Select Aggregate and Parts"
else:
return "Select Aggregate"
def execute(self, context): def execute(self, context):
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
obj = bpy.data.objects.get(self.obj) or context.active_object obj = bpy.data.objects.get(self.obj) or context.active_object
aggregate = ifcopenshell.util.element.get_aggregate(tool.Ifc.get_entity(obj)) aggregate = ifcopenshell.util.element.get_aggregate(tool.Ifc.get_entity(obj))
aggregate_obj = tool.Ifc.get_object(aggregate) aggregate_obj = tool.Ifc.get_object(aggregate)
if self.select_parts:
bpy.ops.bim.select_parts(obj=aggregate_obj.name)
if aggregate_obj in context.selectable_objects: if aggregate_obj in context.selectable_objects:
aggregate_obj.select_set(True) tool.Blender.set_objects_selection(
bpy.context.view_layer.objects.active = aggregate_obj context,
aggregate_obj,
[aggregate_obj],
clear_previous_selection=not self.select_parts,
)
return {"FINISHED"} return {"FINISHED"}
@@ -242,6 +256,7 @@ class BIM_OT_add_part_to_object(bpy.types.Operator, Operator):
part_name=self.part_name, part_name=self.part_name,
) )
class BIM_OT_break_link_to_other_aggregates(bpy.types.Operator, Operator): class BIM_OT_break_link_to_other_aggregates(bpy.types.Operator, Operator):
bl_idname = "bim.break_link_to_other_aggregates" bl_idname = "bim.break_link_to_other_aggregates"
bl_label = "Break link to other aggregates" bl_label = "Break link to other aggregates"
@@ -258,7 +273,7 @@ class BIM_OT_break_link_to_other_aggregates(bpy.types.Operator, Operator):
parts = ifcopenshell.util.element.get_parts(aggregate) parts = ifcopenshell.util.element.get_parts(aggregate)
for part in parts: for part in parts:
pset = ifcopenshell.util.element.get_pset(part, 'BBIM_Linked_Aggregate') pset = ifcopenshell.util.element.get_pset(part, "BBIM_Linked_Aggregate")
pset = tool.Ifc.get().by_id(pset["id"]) pset = tool.Ifc.get().by_id(pset["id"])
ifcopenshell.api.run("pset.remove_pset", tool.Ifc.get(), pset=pset) ifcopenshell.api.run("pset.remove_pset", tool.Ifc.get(), pset=pset)
@@ -272,6 +287,7 @@ class BIM_OT_break_link_to_other_aggregates(bpy.types.Operator, Operator):
return {"FINISHED"} return {"FINISHED"}
class BIM_OT_select_linked_aggregates(bpy.types.Operator, Operator): class BIM_OT_select_linked_aggregates(bpy.types.Operator, Operator):
bl_idname = "bim.select_linked_aggregates" bl_idname = "bim.select_linked_aggregates"
bl_label = "Select linked aggregates" bl_label = "Select linked aggregates"
@@ -62,8 +62,12 @@ class BIM_PT_aggregate(Panel):
row = layout.row(align=True) row = layout.row(align=True)
if AggregateData.data["has_relating_object"]: if AggregateData.data["has_relating_object"]:
row.label(text=AggregateData.data["relating_object_label"], icon="TRIA_UP") row.label(text=AggregateData.data["relating_object_label"], icon="TRIA_UP")
op = row.operator("bim.select_aggregate", icon="OBJECT_DATA", text="")
op.obj = context.active_object.name
op.select_parts = False
op = row.operator("bim.select_aggregate", icon="RESTRICT_SELECT_OFF", text="") op = row.operator("bim.select_aggregate", icon="RESTRICT_SELECT_OFF", text="")
op.obj = context.active_object.name op.obj = context.active_object.name
op.select_parts = True
row.operator("bim.enable_editing_aggregate", icon="GREASEPENCIL", text="") row.operator("bim.enable_editing_aggregate", icon="GREASEPENCIL", text="")
row.operator("bim.add_aggregate", icon="ADD", text="") row.operator("bim.add_aggregate", icon="ADD", text="")
op = row.operator("bim.aggregate_unassign_object", icon="X", text="") op = row.operator("bim.aggregate_unassign_object", icon="X", text="")