-
Notifications
You must be signed in to change notification settings - Fork 309
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
Workplane orientation breaks when "Locating workplane on a vertex". #24
Comments
Thanks for reporting this. I can see how you would expect the behavior to be as you described, but it isn't currently designed to work this way. When you select a face, you have not implicitly selected a workplane. The workplane method is choosing an indeterminate direction because it is not coded to look backwards in the stack for face selections made earlier. Right now the way to do this is to first establish a workplane on a face, and then shift its origin. That does not allow you to utilize the vertices, though, so I can see why you're wanting it to work this way. There are two solutions we could consider. The simplest is to allow the syntax toy expected, by having the workplane method look backwards in the stack for a face selection, and center the wp on the selected vertex. We would also have to handle what happens if you attempt to use a vertex without first choosing a face. The more complex and probably better solution is to simply select the face as the workplane, but then make it possible to project geometry from selections on the object into the workplane. The second option is much more flexible. The logic to select the center of the wp on a Vertex is a round about way to conveniently calculate a single point on the object in the new workplane, but it only let's you do a single point. It would be much better to be able to project any point, or even an edge, into the workplane. |
@dcowden I am not sure I understand. Does it mean the example http://dcowden.github.io/cadquery/examples.html#locating-a-workplane-on-a-vertex is incorrect ? |
@sander76 My apologies, you are right! this should work. I forgot we had contemplated this case already. In the case a vertex is selected, the plane normal will be that of the current workplane's normal, from this line: https://github.com/dcowden/cadquery/blob/master/cadquery/cq.py#L370 This code is expecting that the current CQ object's plane has been oriented to the face already, but i think that's not the case. When a workplane is created from a face, the normal is computed at this line: I think the problem here is that faces() by itself doesnt create a workplane-- so the above is not called. I suspect this may work:
But even if it does, the documentation clearly indicates that the extra workplane() shouldnt be necessary here. I think the right solution is to add code something like this around line 370:
This would ensure that the orientation for a face is honored correctly. I've got a lot of projects going on, so I'm not sure when we could get to this. We'd happily accept a PR if you'd be interested in contributing! |
No problem! I will label this as a good starter issue in case Anyone else is interested in helping |
I was able to recreate this in the current version. I would like to attempt this fix since I want to start contributing to this project while I learn how to use it for my personal projects. Is there anything else I should do for this PR in relation to #149? It seems like @dcowden's proposed fix should solve it as well by checking for the parent's normal. The workplane() code has changed slightly so the fix may not be exactly as described and may take me a little longer to figure out the new equivalent. |
Saturday Aug 11, 2018 at 10:15 GMT
Originally opened as dcowden/cadquery#289
Comparable to the example displayed at http://dcowden.github.io/cadquery/examples.html#locating-a-workplane-on-a-vertex I am trying to draw a cilinder on a cube with the center located at one of the cube's vertices. However when I do that the workplane changes orientation unexpectedly.
Two examples below.
Example 1
Example Two
The text was updated successfully, but these errors were encountered: