mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
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:
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user