mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-28 19:27:10 +00:00
Applying multiple opening objects in bulk
Merry Christmas.
This commit is contained in:
@@ -415,7 +415,7 @@ class BimToolUI:
|
||||
row.label(text="", icon="EVENT_SHIFT")
|
||||
row.label(text="", icon="EVENT_O")
|
||||
|
||||
if len(context.selected_objects) == 2:
|
||||
if len(context.selected_objects) > 1:
|
||||
row.operator("bim.add_opening", text="Apply Void")
|
||||
else:
|
||||
row.operator("bim.add_potential_opening", text="Add Void")
|
||||
|
||||
@@ -34,31 +34,37 @@ class AddOpening(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
if len(context.selected_objects) != 2:
|
||||
cls.poll_message_set("Select two elements to add an opening")
|
||||
if len(context.selected_objects) < 2:
|
||||
cls.poll_message_set("Select openings and a target element")
|
||||
return True
|
||||
|
||||
def _execute(self, context):
|
||||
props = context.scene.BIMModelProperties
|
||||
if len(context.selected_objects) != 2:
|
||||
return {"FINISHED"}
|
||||
selected_objects = context.selected_objects
|
||||
target_object = selected_objects[0]
|
||||
|
||||
# The convention is that element1 is the element and element2 is the opening.
|
||||
obj1, obj2 = context.selected_objects
|
||||
element1 = tool.Ifc.get_entity(obj1)
|
||||
element2 = tool.Ifc.get_entity(obj2)
|
||||
|
||||
opening_objects = [obj for obj in selected_objects if obj != target_object]
|
||||
|
||||
|
||||
for opening_obj in opening_objects:
|
||||
element1 = tool.Ifc.get_entity(target_object)
|
||||
obj1 = target_object
|
||||
element2 = tool.Ifc.get_entity(opening_obj)
|
||||
obj2 = opening_obj
|
||||
|
||||
if not element1 and not element2:
|
||||
return {"FINISHED"} # Both are not IFC objects.
|
||||
|
||||
if element1 and element2:
|
||||
if element1.is_a("IfcOpeningElement") and element2.is_a("IfcOpeningElement"):
|
||||
return {"FINISHED"} # You can't add an opening to another opening.
|
||||
self.report({'INFO'}, "You can't add an opening to another opening.")
|
||||
continue
|
||||
elif not element1.is_a("IfcOpeningElement") and not element2.is_a("IfcOpeningElement"):
|
||||
if element1.is_a("IfcWindow") or element1.is_a("IfcDoor"): # Add a fill to an element.
|
||||
obj1, obj2 = obj2, obj1
|
||||
FilledOpeningGenerator().generate(obj2, obj1, target=obj2.matrix_world.translation)
|
||||
return {"FINISHED"}
|
||||
continue
|
||||
elif element1.is_a("IfcOpeningElement") or element2.is_a("IfcOpeningElement"):
|
||||
if element1.is_a("IfcOpeningElement"): # Reassign an opening to another element.
|
||||
obj1, obj2 = obj2, obj1
|
||||
@@ -69,7 +75,8 @@ class AddOpening(bpy.types.Operator, tool.Ifc.Operator):
|
||||
element1, element2 = element2, element1
|
||||
|
||||
if element1.is_a("IfcOpeningElement"):
|
||||
return {"FINISHED"} # You can't add an opening to another opening.
|
||||
self.report({'INFO'}, "You can't add an opening to another opening.")
|
||||
continue
|
||||
|
||||
if tool.Ifc.is_moved(obj1):
|
||||
blenderbim.core.geometry.edit_object_placement(tool.Ifc, tool.Geometry, tool.Surveyor, obj=obj1)
|
||||
|
||||
Reference in New Issue
Block a user