N00b: CQ-editor + simple assemble example doesn't work?

147 views
Skip to first unread message

s.sevee...@gmail.com

unread,
Apr 15, 2021, 7:02:36 AM4/15/21
to CadQuery
Hello,

Firstly, Thanks so much to all the contributors to the CQ ecosystem. I've been following the project for years. Very pleased to watch the project develop.

I've copied the code from cadquery.readthedocs.io/en/latest/primer.html#assemblies
But the output in CadQuery doesn't seem right. Please see screenshot and code used below.

The colours are not set and the relative placement of the parts doesn't seem to have worked.

I also changed the code to work using 'import cadquery as cq', which compiled fine but outputted the same seemingly incorrect model.


Thanks

Senthil

cq-editor.jpg

from cadquery import *

w = 10
d = 10
h = 10

part1 = Workplane().box(2*w,2*d,h)
part2 = Workplane().box(w,d,2*h)
part3 = Workplane().box(w,d,3*h)

assy = (
    Assembly(part1, loc=Location(Vector(-w,0,h/2)))
    .add(part2, loc=Location(Vector(1.5*w,-.5*d,h/2)), color=Color(0,0,1,0.5))
    .add(part3, loc=Location(Vector(-.5*w,-.5*d,2*h)), color=Color("red"))
)


Jeremy Wright

unread,
Apr 15, 2021, 9:04:54 AM4/15/21
to CadQuery
Hi @Senthil

If you call "show_object(assy)" at the end of your code the assembly will display correctly.

CQ-editor magically displays Workplane objects in default color and default location unless you specifically call "show_object", which can display misleading results in the 3D view.

s.sevee...@gmail.com

unread,
Apr 15, 2021, 9:30:15 AM4/15/21
to CadQuery
Cheers!

Might be worth logging a warning in cq-editor for this scenario, for fellow N00bs.
Reply all
Reply to author
Forward
0 new messages