New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Center assemblies #1558
Comments
Change this: Line 271 in 3451007
to something like?: if len(res.vals()) > 1:
if shapes:= _selectShapes(res.objects):
center = Shape.CombinedCenter(shapes)
res = getattr(res, query.selector_kind)(NearestToPointSelector(center.toTuple()))
val = res.val() Then the original example posted here works as expected. Otherwise can select and tag single object: bumps.faces("<Z").faces(cq.selectors.NearestToPointSelector((0, 0, 0))).tag("centerface")
#...
assy.constrain("roic", "Fixed")
assy.constrain("roic@faces@>Z", "bumps?centerface", "Plane") |
Thanks! Both solutions work. Maybe a deeper issue I was after is that you have to use assemblies to get colors. A simpler implementation would be like below but it's missing colors. It would be nice if the primitives could have colors when displaying. Should I file a feature request for that? Something like
|
No need to use constraints, or modify cq: rows = 8
cols = 8
pitch = 8
dx = cols*pitch
dy = rows*pitch
dz = 3*pitch
#roic
base = cq.Workplane('XY').center(0,0).box(dx,dy,dz, centered=True)
#bumps
r = pitch/2/2
h = (2*r)*2
top = base.faces('>Z').workplane().rarray(pitch,pitch,cols,rows).circle(r).extrude(h/2,combine=False)
assy = cq.Assembly().add(base, color=cq.Color('pink')).add(top, color=cq.Color('gray'))
show_object(assy) |
@chaffra The difference is expected. If you want to get the same results, the code should be written as following (NB: offset=h/2). |
The code below allows me to stack 2 assemblies but I don't know how to center them, so that they have the same center in the XY plane.
The text was updated successfully, but these errors were encountered: