Cadquery: Assembly not as expected, duplicate items appear

36 Views Asked by At

I am trying to make a simple stack of boxes as an assembly. When I create the boxes and visualize them individually they appear to have the correct thickness and position. But when i add them to the assembly, it doesn't look right. I am seeing five boxes in the stack instead of three. What am I doing wrong? The expected output is 3 boxes stacked on top of each other with increasing thicknesses (10, 30, 50) when viewed from the side going down towards the XY plane.

import cadquery as cq

box0 = cq.Workplane("front").box(50,50,50)
box1 = box0.faces(">Z").workplane().box(50,50,30, combine =False)
box2 = box1.faces(">Z").workplane().box(50,50,10, combine =False)
assy = cq.Assembly()
assy.add(box0, name =  "0").add(box1, name =  "1").add(box2, name =  "2")

Incorrect assembly output

1

There are 1 best solutions below

0
On

I found my mistake: I had to center the new objects correctly. The following code gives the right output:

box0 = cq.Workplane("front").box(50,50,50)

box1 = box0.faces(">Z").workplane().box(50,50,30, centered = [1,1,0], combine =False)

box2 = box1.faces(">Z").workplane().box(50,50,10, centered = [1,1,0],  combine =False)

assy = cq.Assembly()

assy.add(box0, name =  "0").add(box1, name =  "1").add(box2, name =  "2")