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

How can you center a geometry on the document before writing #175

Closed
theomega opened this issue Jan 25, 2021 · 4 comments
Closed

How can you center a geometry on the document before writing #175

theomega opened this issue Jan 25, 2021 · 4 comments

Comments

@theomega
Copy link
Contributor

Lets assume I have the following svg as input:
https://gist.github.com/64f4bff934c9059e642806bfe625a03e

How can I center the actual geometry on an A4 paper in landscape before using write. Reason for not using write is that I actually want to use the output in the vype-gcode plugin.

I tried the following:
vpype read LabradorLowPoly.svg pagesize --landscape a4 scaleto 29cm 19cm frame show -g --unit mm

Which leads to:
Screenshot from 2021-01-25 16-12-02

Not bad, at least the size matches now, but how can I center this on the page?
I checked translate but I ran into two issues:
a) I don't know how to provide negative offsets
b) I would not know which offsets to provide

What am I missing?

@theomega
Copy link
Contributor Author

I found out how to provide negative values, it is super hacky though. The problem is you need to prevent click from interpreting the minus sign as a start of a cmd line parameter. You need to quote the number and add a space before the minus sign.

vpype read LabradorLowPoly.svg  pagesize --landscape a4 scaleto 30cm 20cm translate ' -10cm' ' -3cm' frame show -g --unit mm

@abey79
Copy link
Owner

abey79 commented Jan 25, 2021

You put the finger right on vpype's missing piece.

First, for translate (standard Unix way to deal with this): translate -- -10cm -3cm. The -- notation means "end of options" so what follows is not interpreted as option even though it starts with -.

Then, a new layout command will address this issue more elegantly than write --center, which has many shortcomings as you rightly noticed. See #168. I'm hoping to release vpype with this addition in a matter of days. In the mean time, if you installed with pip you can get it from master:

pip install -U git+https://github.com/abey79/vpype#egg=vpype

If you used the installer, you can download one made from master here: https://github.com/abey79/vpype/suites/1894012677/artifacts/37071956

@abey79
Copy link
Owner

abey79 commented Jan 25, 2021

Side note: if you havent already, consider joining the drawingbots discord server. I'm very often online and available for casual help.

https://drawingbots.net
https://discord.com/invite/XHP3dBg

@theomega
Copy link
Contributor Author

Great, that new branch worked perfectly! Thanks

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

No branches or pull requests

2 participants