-
Notifications
You must be signed in to change notification settings - Fork 7
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
Permit vpype-gcode expression substitution into patterns. #29
Comments
*Also, it's not clear if it could be integrated the other way since you clearly have {} replacements for those values in places too if that could be done rather than the format thing it might be more useful. |
Could also >>> template = "{layer_id*20}mm"
>>> vars = {"layer_id": 2}
>>> eval("f'{}'".format(template), vars)
'40mm' This would mean that you couldn't put a single quote in the template string, but that could be mitigated somewhat by changing to |
This would also let you do awesome stuff like
|
I think @abey79 struck a balance here with the combination of safety and power. I believe the vpype evaluation actually would permit some similar code. I'm just not well versed enough on it. He spent a while coming up with the formatting and my hopes for vpype-gcode is integration though that's seeming a bit far fetched, but I still try to adhere as best as I can to the regular API of vpype to facilitate that. |
It randomly occurred to me that using the jinja templating engine might be a good avenue as well. In retrospect, possibly for vpype expression as well. Amongst the advantages I can think of:
|
If, we, for example needed gcode that set some value 20mm over per
layer_id
currently there is no set of methods that would allow this.So the template would have something like %layer_id*20*mm% and that would be substituted by the correct value.
Breaking changes
Using expression substitution from vpype proper requires that any direct use of
%
must be%%
to avoid parsing confusion.The text was updated successfully, but these errors were encountered: