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