Minor fix to "select multiple IFC class" implementation

This commit is contained in:
Dion Moult
2023-11-23 11:18:04 +11:00
parent a18cd0eeab
commit f2e56f8128
2 changed files with 9 additions and 8 deletions
@@ -62,8 +62,7 @@ class BIM_PT_class(Panel):
else:
row = self.layout.row(align=True)
row.label(text=IfcClassData.data["name"])
op = row.operator("bim.select_ifc_class", text="", icon="RESTRICT_SELECT_OFF")
op.ifc_class = IfcClassData.data["ifc_class"]
row.operator("bim.select_ifc_class", text="", icon="RESTRICT_SELECT_OFF")
row.operator("bim.unlink_object", icon="UNLINKED", text="")
if IfcClassData.data["can_reassign_class"]:
row.operator("bim.enable_reassign_class", icon="GREASEPENCIL", text="")
@@ -431,15 +431,17 @@ class SelectIfcClass(Operator):
bl_idname = "bim.select_ifc_class"
bl_label = "Select IFC Class"
bl_options = {"REGISTER", "UNDO"}
ifc_class: StringProperty()
def execute(self, context):
objects = bpy.context.selected_objects
for object in objects:
element = tool.Ifc.get_entity(object)
element_class = element.is_a()
for elem in tool.Ifc.get().by_type(element_class):
obj = tool.Ifc.get_object(elem)
classes = set()
for obj in objects:
element = tool.Ifc.get_entity(obj)
if element:
classes.add(element.is_a())
for cls in classes:
for element in tool.Ifc.get().by_type(cls):
obj = tool.Ifc.get_object(element)
if obj:
obj.select_set(True)
return {"FINISHED"}