Select multiple arrays at one time, from various parts. Deselect non-compliant objects.

This commit is contained in:
Ryan Schultz
2023-11-04 11:35:30 -05:00
parent 4404470d91
commit 66f57f90df
@@ -248,18 +248,25 @@ class SelectAllArrayObjects(bpy.types.Operator):
return True return True
def execute(self, context): def execute(self, context):
object = context.active_object objects = context.selected_objects
for object in objects:
element = tool.Ifc.get_entity(object) element = tool.Ifc.get_entity(object)
if not element:
self.report({"ERROR"}, f"Non IFC objects, were deselected.")
object.select_set(False)
if element:
array_pset = ifcopenshell.util.element.get_pset(element, "BBIM_Array") array_pset = ifcopenshell.util.element.get_pset(element, "BBIM_Array")
if not array_pset: if not array_pset:
self.report({"ERROR"}, f"Object is not part of an array.") self.report({"ERROR"}, f"Objects not part of an array, were deselected.")
return {"CANCELLED"} object.select_set(False)
if array_pset:
try: try:
parent_element = tool.Ifc.get().by_guid(array_pset["Parent"]) parent_element = tool.Ifc.get().by_guid(array_pset["Parent"])
except RuntimeError: except RuntimeError:
self.report({"ERROR"}, f"Couldn't find array parent by guid '{array_pset['Parent']}'") self.report({"ERROR"}, f"Objects that don't have an array parent, were deselected.")
return {"CANCELLED"} object.select_set(False)
array_objects = tool.Blender.Modifier.Array.get_all_objects(parent_element) array_objects = tool.Blender.Modifier.Array.get_all_objects(parent_element)
tool.Blender.set_objects_selection( tool.Blender.set_objects_selection(