Fix bug where adding a duct failed due to no container obj being calculated

This commit is contained in:
Dion Moult
2024-07-20 15:49:05 +10:00
parent 8f2e8ec64d
commit 48026c7a50
@@ -144,6 +144,10 @@ class AddConstrTypeInstance(bpy.types.Operator):
if self.from_invoke and str(self.relating_type_id) in AuthoringData.data["relating_type_id"]:
props.relating_type_id = str(self.relating_type_id)
self.container_obj = None
if container := tool.Root.get_default_container():
self.container_obj = tool.Ifc.get_object(container)
relating_type = tool.Ifc.get().by_id(int(relating_type_id))
ifc_class = relating_type.is_a()
instance_class = ifcopenshell.util.type.get_applicable_entities(ifc_class, tool.Ifc.get().schema)[0]
@@ -192,10 +196,6 @@ class AddConstrTypeInstance(bpy.types.Operator):
obj.location = context.scene.cursor.location
self.container_obj = None
if container := tool.Root.get_default_container():
self.container_obj = tool.Ifc.get_object(container)
bpy.ops.bim.assign_class(obj=obj.name, ifc_class=instance_class)
tool.Blender.remove_data_block(mesh) # Remove "Instance" mesh