Skip to content
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

moving a workplane origin #577

Open
billingsley-john opened this issue Jan 13, 2021 · 5 comments
Open

moving a workplane origin #577

billingsley-john opened this issue Jan 13, 2021 · 5 comments
Labels
question Further information is requested

Comments

@billingsley-john
Copy link

Hi, I have been using cadquery to produce swept solids. To position the 'end faces' of the solid at specified positions I have been using code similar to this:

solid = cq.Workplane("XZ").moveTo(50, 0).workplane()
solid = solid.polyline([(-10, 10), (10, 10), (10, -10), (-10, -10)]).close()

Previously, this would create a 20x20 square centered on (50, 0). However, this doesn't work anymore, the square now centers on (0, 0).

Could this be a bug, or maybe this is now the wrong approach to take?

My understanding was that .moveTo(50, 0).workplane() would essentially create a new origin at (50, 0) so that the polyline would be placed correctly.

I also notice that if .circle() is used instead of .polyline(), a circle is correctly centered at (50, 0).

Any help with this problem would be greatly appreciated.

Thanks,

John

@jmwright
Copy link
Member

@billingsley-john Are you running on the latest master of cadquery? I can't replicate your problem with the latest binary development release of CQ-editor which may be a little bit behind master.

Screenshot from 2021-01-13 09-57-49

You could also try moving the center of the workplane. moveTo is more of a 2D drawing method if I remember correctly.

You can try this, which also works for me in CQ-editor.

solid = cq.Workplane("XZ").center(50, 0).workplane()
solid = solid.polyline([(-10, 10), (10, 10), (10, -10), (-10, -10)]).close()

@billingsley-john
Copy link
Author

Hi @jmwright,

Yes, I am using the latest cq master (installed today), and your suggestion of using center() worked great! Not too sure what's going on locally for me with moveTo() but at least there is a viable alternative.

Thank you very much!

@adam-urbanczyk
Copy link
Member

adam-urbanczyk commented Jan 13, 2021

This is due to #532 (solving #314). To get the olde behaviour you nee to use centerOption="CenterOfMass".

solid = cq.Workplane("XZ").moveTo(50, 0).workplane(centerOption="CenterOfMass")
solid = solid.polyline([(-10, 10), (10, 10), (10, -10), (-10, -10)]).close()

@adam-urbanczyk adam-urbanczyk added the question Further information is requested label Jan 13, 2021
@marcus7070
Copy link
Member

solid = cq.Workplane("XZ").center(50, 0).workplane()
solid = solid.polyline([(-10, 10), (10, 10), (10, -10), (-10, -10)]).close()

The .workplane() isn't needed there, .center(x, y) creates a new plane already.

@billingsley-john
Copy link
Author

Great, thank you all for your responses!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants