You can now bulk assign / unassign construction types

This commit is contained in:
Dion Moult
2021-03-09 14:25:04 +11:00
parent 1f68c3f612
commit ebfaeafeee
@@ -18,21 +18,22 @@ class AssignType(bpy.types.Operator):
def execute(self, context): def execute(self, context):
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
related_object = bpy.data.objects.get(self.related_object) if self.related_object else bpy.context.active_object relating_type = self.relating_type or int(context.active_object.BIMTypeProperties.relating_type)
oprops = related_object.BIMObjectProperties related_objects = (
props = related_object.BIMTypeProperties [bpy.data.objects.get(self.related_object)] if self.related_object else bpy.context.selected_objects
relating_type = self.relating_type or int(props.relating_type) )
assign_type.Usecase( for related_object in related_objects:
self.file, oprops = related_object.BIMObjectProperties
{ assign_type.Usecase(
"related_object": self.file.by_id(oprops.ifc_definition_id), self.file,
"relating_type": self.file.by_id(relating_type), {
}, "related_object": self.file.by_id(oprops.ifc_definition_id),
).execute() "relating_type": self.file.by_id(relating_type),
Data.load(oprops.ifc_definition_id) },
).execute()
if self.file.by_id(relating_type).RepresentationMaps: Data.load(oprops.ifc_definition_id)
bpy.ops.bim.map_representations(product_id=oprops.ifc_definition_id, type_product_id=relating_type) if self.file.by_id(relating_type).RepresentationMaps:
bpy.ops.bim.map_representations(product_id=oprops.ifc_definition_id, type_product_id=relating_type)
bpy.ops.bim.disable_editing_type(obj=related_object.name) bpy.ops.bim.disable_editing_type(obj=related_object.name)
return {"FINISHED"} return {"FINISHED"}
@@ -45,15 +46,18 @@ class UnassignType(bpy.types.Operator):
def execute(self, context): def execute(self, context):
self.file = IfcStore.get_file() self.file = IfcStore.get_file()
related_object = bpy.data.objects.get(self.related_object) if self.related_object else bpy.context.active_object related_objects = (
oprops = related_object.BIMObjectProperties [bpy.data.objects.get(self.related_object)] if self.related_object else bpy.context.selected_objects
unassign_type.Usecase( )
self.file, for related_object in related_objects:
{ oprops = related_object.BIMObjectProperties
"related_object": self.file.by_id(oprops.ifc_definition_id), unassign_type.Usecase(
}, self.file,
).execute() {
Data.load(oprops.ifc_definition_id) "related_object": self.file.by_id(oprops.ifc_definition_id),
},
).execute()
Data.load(oprops.ifc_definition_id)
return {"FINISHED"} return {"FINISHED"}