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,10 +18,12 @@ 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)
related_objects = (
[bpy.data.objects.get(self.related_object)] if self.related_object else bpy.context.selected_objects
)
for related_object in related_objects:
oprops = related_object.BIMObjectProperties oprops = related_object.BIMObjectProperties
props = related_object.BIMTypeProperties
relating_type = self.relating_type or int(props.relating_type)
assign_type.Usecase( assign_type.Usecase(
self.file, self.file,
{ {
@@ -30,7 +32,6 @@ class AssignType(bpy.types.Operator):
}, },
).execute() ).execute()
Data.load(oprops.ifc_definition_id) Data.load(oprops.ifc_definition_id)
if self.file.by_id(relating_type).RepresentationMaps: 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.map_representations(product_id=oprops.ifc_definition_id, type_product_id=relating_type)
@@ -45,7 +46,10 @@ 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 = (
[bpy.data.objects.get(self.related_object)] if self.related_object else bpy.context.selected_objects
)
for related_object in related_objects:
oprops = related_object.BIMObjectProperties oprops = related_object.BIMObjectProperties
unassign_type.Usecase( unassign_type.Usecase(
self.file, self.file,