gumyr / build123d

A python CAD programming library
Apache License 2.0
382 stars 72 forks source link

BuildPart.add() doesn't work properly with deeply nested Compounds #607

Open cyberhuman opened 2 months ago

cyberhuman commented 2 months ago
from ocp_vscode import show
from build123d import *

box = Box(10, 10, 10)
comp_box = Compound(children=[box])

sphere = Sphere(6.5)
comp_sphere = Compound(children=[Compound(children=[Compound(children=[sphere])])])

with BuildPart() as nested:
    add(comp_box)
    add(comp_sphere, mode=Mode.SUBTRACT)

with BuildPart() as nested_workaround:
    add(comp_box)
    add(comp_sphere.solids(), mode=Mode.SUBTRACT)

show(
    comp_box.cut(comp_sphere).moved(Pos(-11)),
    nested.part,
    nested_workaround.part.moved(Pos(+11)),
)

image