Constants in LDraw files
2022-07-07, 20:42 (This post was last modified: 2022-07-07, 20:44 by Nils Schmidt.)
2022-07-07, 20:42 (This post was last modified: 2022-07-07, 20:44 by Nils Schmidt.)
(2022-07-06, 12:31)Cam's Bricks Wrote: I am pretty sure the answer is "no, no, not ever, no thanks, that is a terrible idea" BUT I wanted to ask if there is support for variables in the LDraw file format?
It would probably take support of all the editors and renders which is probably causing someone's eyebrows to make odd shapes as even type this out
I am someone who enjoys the "make it once and for all use cases", so the pragmatic nature of making a lot of similar parts that have one or two changes for each iteration feels quite bothersome.
I did a quick implementation to try it out.
One difficulty is to parse the occurences in an efficient manner, otherwise I would need to try to replace every substring of a line with a potential constant which slows down the parsing of the file significantly.
I am not sure if I am going to finally implement this in LDPE.
But I suggest to use global constants instead of variables.
A variable implies some kind of re-assignment, a scope or a calculation.
For this I would create some kind of unofficial specification for the use of a scripting language (LDCad for example supports lua scripts ).