[OpenSCAD] new "Special Variable"?

Ivo ivo.knutsel at gmail.com
Wed May 6 03:33:48 EDT 2015


We already have the stack of modules available as variables:

http://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#parent_module.28n.29_and_.24parent_modules

A nice example of this feature is described here :
https://github.com/openscad/openscad/pull/460#issuecomment-23049813

It would have been nice if parent_module() returns a vector of [modulename,
filename], that way we would have better information about the context.
[modulename, filename, path, timestamp] would be even better. It would also
clarify the issue : does file_name() return the file location of declaration
or of use. With that feature :

name = parent_module(0);
echo(name[1]); 

would give you the current module definition

name = parent_module($parent_modules);
echo(name[1]); 

would give you the current file.

As for a "number of times F6 was pressed" counter, there is no place to
store that. It should not go in the file (only i edit the file) and it is
impossible for openscad to decide if this is actually a new version. Version
control systems can output version files which you can include in the
source.

With all this meta information available, it would be nice to get rid of the
"echo" in echo() and be able to format stuff prettier. I'd like to be able
to generate openscad files in openscad.





--
View this message in context: http://forum.openscad.org/new-Special-Variable-tp12579p12592.html
Sent from the OpenSCAD mailing list archive at Nabble.com.




More information about the Discuss mailing list