enable/disable editing representation items to affect all selected objects

To simplify the process when you need to review representation items / their styles for multiple objects.
This commit is contained in:
Andrej730
2025-07-23 16:06:58 +05:00
parent ed65c039dc
commit 3dde609519
2 changed files with 24 additions and 4 deletions
@@ -2373,11 +2373,14 @@ class FlipObject(bpy.types.Operator):
class EnableEditingRepresentationItems(bpy.types.Operator, tool.Ifc.Operator):
bl_idname = "bim.enable_editing_representation_items"
bl_label = "Enable Editing Representation Items"
bl_description = "Enable editing representation items for all selected objects."
bl_options = {"REGISTER", "UNDO"}
def _execute(self, context):
obj = tool.Geometry.get_active_or_representation_obj()
for obj in tool.Geometry.get_selected_objects_with_representations():
self.process_obj(obj)
def process_obj(self, obj: bpy.types.Object) -> None:
props = tool.Geometry.get_object_geometry_props(obj)
props.is_editing = True
@@ -2455,12 +2458,13 @@ class EnableEditingRepresentationItems(bpy.types.Operator, tool.Ifc.Operator):
class DisableEditingRepresentationItems(bpy.types.Operator, tool.Ifc.Operator):
bl_idname = "bim.disable_editing_representation_items"
bl_label = "Disable Editing Representation Items"
bl_description = "Disable editing representation items for all selected objects"
bl_options = {"REGISTER", "UNDO"}
def _execute(self, context):
obj = tool.Geometry.get_active_or_representation_obj()
assert obj
tool.Geometry.get_object_geometry_props(obj).is_editing = False
for obj in tool.Geometry.get_selected_objects_with_representations():
props = tool.Geometry.get_object_geometry_props(obj)
props.is_editing = False
class RemoveRepresentationItem(bpy.types.Operator, tool.Ifc.Operator):
+16
View File
@@ -2302,3 +2302,19 @@ class Geometry(bonsai.core.tool.Geometry):
def name_item_object(cls, obj: bpy.types.Object, item: ifcopenshell.entity_instance) -> None:
assert (data := obj.data)
obj.name = data.name = f"Item/{item.is_a()}/{item.id()}"
@classmethod
def get_selected_objects_with_representations(cls) -> set[bpy.types.Object]:
objects: set[bpy.types.Object] = set()
props = tool.Geometry.get_geometry_props()
for obj in tool.Blender.get_selected_objects():
if not obj.data:
continue
if not tool.Ifc.get_entity(obj):
if tool.Geometry.is_representation_item(obj):
assert (obj := props.representation_obj)
objects.add(obj)
continue
continue
objects.add(obj)
return objects