(partially) Fix #1737 : Active object swaps to opening

Void operator would swap active object if opening IFC type is not set
Also changed the modifier creation/update logic
to accomodate for user potentially breaking things
This commit is contained in:
Gorgious
2021-09-20 10:23:56 +02:00
parent 8fb218c335
commit 500c7cdc37
@@ -55,21 +55,20 @@ class AddOpening(bpy.types.Operator):
"element": self.file.by_id(element_id),
},
)
Data.load(IfcStore.get_file(), element_id)
Data.load(self.file, element_id)
has_modifier = False
for modifier in obj.modifiers:
if modifier.type == "BOOLEAN" and modifier.object and modifier.object == opening:
has_modifier = True
break
if not has_modifier:
try:
modifier = next(m for m in obj.modifiers if m.type == "BOOLEAN" and m.object == opening)
except StopIteration:
modifier = obj.modifiers.new("IfcOpeningElement", "BOOLEAN")
modifier.operation = "DIFFERENCE"
modifier.object = opening
finally:
modifier.operation = "DIFFERENCE"
modifier.solver = "EXACT"
modifier.use_self = True
modifier.operand_type = "OBJECT"
context.view_layer.objects.active = obj
return {"FINISHED"}