The BoxSelector()
is a selection tool in the CadQuery library that allows the user to select a group of objects within a certain 3D space.
box = cq.BoxSelector(xmin, ymin, zmin, xmax, ymax, zmax)
result = box.select(objects)
xmin
(float): minimum x-coordinate of the 3D selection boxymin
(float): minimum y-coordinate of the 3D selection boxzmin
(float): minimum z-coordinate of the 3D selection boxxmax
(float): maximum x-coordinate of the 3D selection boxymax
(float): maximum y-coordinate of the 3D selection boxzmax
(float): maximum z-coordinate of the 3D selection boxobjects
(list): a list of CadQuery objects to be selected fromresult
(list): a list of CadQuery objects within the selection boximport cadquery as cq
# create some objects
box1 = cq.Workplane("XY").rect(5,5).extrude(2)
box2 = cq.Workplane("XY").rect(10,10).extrude(2)
# combine them into a compound object
compound = box1.union(box2.translate((5,5,0)))
# create the selector
selector = cq.BoxSelector(0,0,0,7,7,2)
# select the objects
result = selector.select([compound])
# display the result
show_object(result)
This code will create two boxes, combine them into a compound object, and then use the BoxSelector()
to select only the portion of the compound object within a 7x7x2 box starting at the origin. The resulting object will be displayed using the show_object()
function.