mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 06:58:56 +00:00
Bonsai: sync filling placements on wall regen
recalculate_walls commits the wall's own placement to IFC before recreating its geometry but did not touch its fillings. A door moved along the wall's reference line therefore stayed cut at its old position when the user pressed SHIFT+G on the wall, because the wall recut ran against the still-stale opening placement in IFC. Walk each wall's HasOpenings and, for every filling whose Blender matrix_world differs from its committed IFC placement (tool.Ifc.is_moved), commit the filling's placement and propagate the new matrix to the enclosing opening via ifcopenshell.api.geometry.edit_object_placement. The subsequent recreate_wall pass then sees the fresh opening positions and cuts at the right spot. Generated with the assistance of an AI coding tool.
This commit is contained in:
@@ -3148,6 +3148,26 @@ class Model(bonsai.core.tool.Model):
|
|||||||
obj = tool.Ifc.get_object(rel.RelatingElement)
|
obj = tool.Ifc.get_object(rel.RelatingElement)
|
||||||
tool.Geometry.commit_placement_if_moved(obj)
|
tool.Geometry.commit_placement_if_moved(obj)
|
||||||
queue.add((rel.RelatingElement, obj))
|
queue.add((rel.RelatingElement, obj))
|
||||||
|
|
||||||
|
# Sync filling and opening placements so subsequent wall recuts
|
||||||
|
# operate on the up-to-date opening positions — a filling moved
|
||||||
|
# along the wall's reference line otherwise stays cut at its old
|
||||||
|
# spot.
|
||||||
|
for element, wall in queue:
|
||||||
|
if not wall:
|
||||||
|
continue
|
||||||
|
for rel in getattr(element, "HasOpenings", []) or []:
|
||||||
|
opening = rel.RelatedOpeningElement
|
||||||
|
for fill_rel in getattr(opening, "HasFillings", []) or []:
|
||||||
|
filling = fill_rel.RelatedBuildingElement
|
||||||
|
filling_obj = tool.Ifc.get_object(filling)
|
||||||
|
if filling_obj is None or not tool.Ifc.is_moved(filling_obj):
|
||||||
|
continue
|
||||||
|
bonsai.core.geometry.edit_object_placement(tool.Ifc, tool.Geometry, tool.Surveyor, obj=filling_obj)
|
||||||
|
ifcopenshell.api.geometry.edit_object_placement(
|
||||||
|
tool.Ifc.get(), product=opening, matrix=filling_obj.matrix_world
|
||||||
|
)
|
||||||
|
|
||||||
for element, wall in queue:
|
for element, wall in queue:
|
||||||
if not wall:
|
if not wall:
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user