-
Notifications
You must be signed in to change notification settings - Fork 294
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
Specify which corner to use #1708
Comments
Specify the import cadquery as cq
a = cq.Workplane("XY")
a = a.box(9, 20, 4)
a = a.vertices(">X and <Y and >Z") # or as: ">XZ and <Y"
a = a.workplane(centerOption="CenterOfMass")
a = a.sphere(1) See also the docs example Locating a Workplane on a vertex. |
I suppose creating the workplane is not needed for simply adding the sphere or box. You would typically create the new workplane say in the following scenario where you are building on a selected face and vertex: a = cq.Workplane("XY")
a = a.box(9, 20, 4)
a = a.faces("<Y").vertices(">XZ")
a = a.workplane(centerOption="CenterOfMass")
# now the plane normal is in -Y dir, with center at selected corner
a = a.circle(2).extrude(5) |
Thanks @lorenzncode Unless I am completely misunderstanding what you are suggesting in both comments, and the example you are referring (which I read before submitting the issue), this is not what I want. I am able to select the desired workplane just fine as in my examples. The problem is that the second box (the sphere in your example), is placed on that workplane using a vertex which is the one I want in the
vs
The first is what I want but mirrored on the XZ plane. I know I could do the mirroring (or rotating, or translating), but the example is obviously a simplification of the actual part that I am designing, so I really want to avoid mirroring, rotating or translating because that would include a whole lot of complexity |
I guess one possible solution is
which works fine with both Is this the best option? |
OK I see, it could be done like this. import cadquery as cq
# a, b are symmetric in XZ
a = cq.Workplane("XY")
a = a.box(9, 20, 4)
a = a.faces(">Y")
a = a.workplane(6.5) # offset workplane in normal dir
a = a.box(4, 4, 13)
b = cq.Workplane("XY")
b = b.box(9, 20, 4)
b = b.faces("<Y")
b = b.workplane(6.5) # offset workplane in normal dir
b = b.box(4, 4, 13) I'd prefer your solution though to extrude the shape. a = a.workplane()
a = a.rect(4,4).extrude(13) and then with this solution you can also use a = a.sketch().rect(4, 4).finalize().extrude(13) |
Got it thanks, and you also managed to let me start understanding sketches which have been puzzling me for a while! |
This does what I want on one face
however I want it on the other face, so I try
but that uses the "wrong" corner of the box and it goes wrong. Using
centered=[1,1,0]
in this second instance makes it slightly less wrong.I guess I can fix this by either translating or mirroring the second box (or the whole thing), but that's a pain to get the appropriate values (or mirror surface) right in a parametric correct way. Is there a cleaner way?
The text was updated successfully, but these errors were encountered: