-
Notifications
You must be signed in to change notification settings - Fork 289
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
Assemblies with Two Planar Constraints #479
Comments
When I recreate your last example @jmwright, I consistently get the blue box up the other way. What CadQuery commit are you using? I'm on 7f26c3b. I know there is a little bit of randomness in the solver and this example is probably a bad test, but I don't like the thought of assemblies flipping sides like that depending on which machine generates them! |
@adam-urbanczyk, is applying a ie. does this code: assy.constrain("FIRST@faces@>Z", "SECOND@faces@<Z", "Plane") wind up giving the solver the same mathematical constraints as this code: assy.constrain("FIRST@faces@>Z", "SECOND@faces@<Z", "Axis")
assy.constrain("FIRST@faces@>Z", "SECOND@faces@<Z", "Point") |
@marcus7070 Sorry to confuse the issue. I accidentally posted the screenshot from an earlier iteration of the script. With the script that I posted above (which you ran), I get the same result that you show in your screenshot. |
@marcus7070 is right, you probably wanted this: import cadquery as cq
from cadquery import Vector, Color, Assembly, Location
w = 10
d = 10
h = 10
part1 = cq.Workplane().box(2*w,2*d,h)
part2 = cq.Workplane().box(w,d,2*h)
assy = (
Assembly(part1, name="FIRST")
.add(part2, color=Color(0,0,1,0.5), name="SECOND")
)
assy.constrain("FIRST@faces@<Z", "SECOND@faces@<Z", "Axis")
assy.constrain("FIRST@faces@>Y", "SECOND@faces@<Y", "Axis")
assy.constrain("FIRST@edges@>Y and >Z", "SECOND@edges@>Y and >Z", "Point")
assy.solve()
show_object(assy) |
Maybe I used the name With the current constraint system you can use |
I'm guessing that I won't be the first person caught by that, but let's not worry about changing it yet. I need to live with the new constraint system for awhile, and will shift my thinking to points and axes as that seems to be the way to set up the kinds of constraints that I would normally be using. I'm going to close this for now and if it keeps coming up among the community we can revisit changes to the plane constraint. |
I was attempting to put together an example so I could ask about adding offsets to planar constraints, and came across what seems like a constraint solving bug, at least on the surface.
This code works fine:
But this code ends up with with the second part inside the first with seemingly no relation to the intended relationship to the first part or the origin.
I've tried multiple other variations, and each set of two similar planar constraints cause this behavior. I would expect the assembly to solve to something where no part is inside another, but maybe I'm missing something obvious that makes my constraints unsolvable.
The text was updated successfully, but these errors were encountered: