You can now reassign classes in bulk

This commit is contained in:
Dion Moult
2021-03-03 21:16:51 +11:00
parent 0b39226869
commit 04abadac22
@@ -52,24 +52,26 @@ class DisableReassignClass(bpy.types.Operator):
class ReassignClass(bpy.types.Operator): class ReassignClass(bpy.types.Operator):
bl_idname = "bim.reassign_class" bl_idname = "bim.reassign_class"
bl_label = "Reassign IFC Class" bl_label = "Reassign IFC Class"
obj: bpy.props.StringProperty()
def execute(self, context): def execute(self, context):
obj = bpy.context.active_object objects = [bpy.data.objects.get(self.obj)] if self.obj else bpy.context.selected_objects
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
predefined_type = bpy.context.scene.BIMRootProperties.ifc_predefined_type predefined_type = bpy.context.scene.BIMRootProperties.ifc_predefined_type
if predefined_type == "USERDEFINED": if predefined_type == "USERDEFINED":
predefined_type = bpy.context.scene.BIMRootProperties.ifc_userdefined_type predefined_type = bpy.context.scene.BIMRootProperties.ifc_userdefined_type
product = reassign_class.Usecase( for obj in objects:
self.file, product = reassign_class.Usecase(
{ self.file,
"product": self.file.by_id(obj.BIMObjectProperties.ifc_definition_id), {
"ifc_class": bpy.context.scene.BIMRootProperties.ifc_class, "product": self.file.by_id(obj.BIMObjectProperties.ifc_definition_id),
"predefined_type": predefined_type, "ifc_class": bpy.context.scene.BIMRootProperties.ifc_class,
}, "predefined_type": predefined_type,
).execute() },
obj.name = "{}/{}".format(product.is_a(), "/".join(obj.name.split("/")[1:])) ).execute()
IfcStore.link_element(product, obj) obj.name = "{}/{}".format(product.is_a(), "/".join(obj.name.split("/")[1:]))
bpy.context.active_object.BIMObjectProperties.is_reassigning_class = False IfcStore.link_element(product, obj)
obj.BIMObjectProperties.is_reassigning_class = False
return {"FINISHED"} return {"FINISHED"}