This page was generated from docs/documents/notebooks/design/boolean_operations.ipynb.
Interactive online version: Binder badge - Download notebook -

Boolean Operations

Boolean operations in ada-py can be applied to any physical object or to any part in the assembly (including the top-level Assembly object). Any boolean applied to a part will automatically be applied to its children. Any primitive can be used as a boolean.

[1]:
import ada

Use the add_boolean method (which is available on all physical objects and Part objects) to add any primitive as a boolean.

[2]:
cyl = ada.PrimCyl('cyl', (0,0,0), (0,0,1), 0.2)
pl = ada.Plate('pl', [(0,0), (1,0), (1,1), (0,1)], 0.01, origin=(-0.5,-0.5,0), n=(0,0,1), xdir=(1,0,0))
pl.add_boolean(cyl)
pl.show()
[2]:
[3]:
pl_and_cyl_p = ada.Part('myPart') / (pl, cyl)
pl_and_cyl_p.show()
[3]:

When applying a boolean to a Part, it will automatically apply it to all objects recursively underneath the given Part level.

[4]:
cyl = ada.PrimCyl('cyl', (0,0,0), (0,0,1), 0.2)
pl = ada.Plate('pl', [(0,0), (1,0), (1,1), (0,1)], 0.01, origin=(-0.5,-0.5,0), n=(0,0,1), xdir=(1,0,0))
pl_copy = pl.copy_to('pl2', (-0.5,-0.5, 0.7))
p = ada.Part('myPart') / (pl, pl_copy)
p.add_boolean(cyl)
p.show()
[4]: