discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

new "Special Variable"?

J
jellsworth
Wed, May 6, 2015 3:01 AM

Nice!

Thanks,
Jerry E

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

Nice! Thanks, Jerry E -- View this message in context: http://forum.openscad.org/new-Special-Variable-tp12579p12590.html Sent from the OpenSCAD mailing list archive at Nabble.com.
R
runsun
Wed, May 6, 2015 6:48 AM

Also, I'd like to have $date and $now.

OpenSCAD version is based on date, which I like very much. I've not seen any
other program do so. Very often I find a program on the net, it says version
2.3.1 or something, but who knows it could be as old as 20 years back.

Using date/time immediately gives a sense of how recent the program is. I'd
prefer it that way. Before I start using git, I labeled my "versions" by
dates like 20150503-1. Year always up front so they can be sorted.

Another usage of $date and $now: logging --- if you want to output echo
to a file for logging purpose.

yvette wrote

hi,

any way we can get the filename(s) being built stuffed into a special
variable?

like, say, $fileName?  or $fileNameArray?


$  Runsun Pan, PhD

$ -- OpenScad_DocTest: doc and unit test ( Github , Thingiverse  )

$ -- hash parameter model: here , here

$ -- Linux Mint 17.1 Rebecca x64  + OpenSCAD 2015.03.15/2015.04.01.nightly

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

Also, I'd like to have *$date* and *$now*. OpenSCAD version is based on date, which I like very much. I've not seen any other program do so. Very often I find a program on the net, it says version 2.3.1 or something, but who knows it could be as old as 20 years back. Using date/time immediately gives a sense of how recent the program is. I'd prefer it that way. Before I start using git, I labeled my "versions" by dates like 20150503-1. Year always up front so they can be sorted. Another usage of *$date* and *$now*: logging --- if you want to output echo to a file for logging purpose. yvette wrote > hi, > > any way we can get the filename(s) being built stuffed into a special > variable? > > like, say, $fileName? or $fileNameArray? ----- $ Runsun Pan, PhD $ -- OpenScad_DocTest: doc and unit test ( Github , Thingiverse ) $ -- hash parameter model: here , here $ -- Linux Mint 17.1 Rebecca x64 + OpenSCAD 2015.03.15/2015.04.01.nightly -- View this message in context: http://forum.openscad.org/new-Special-Variable-tp12579p12591.html Sent from the OpenSCAD mailing list archive at Nabble.com.
I
Ivo
Wed, May 6, 2015 7:33 AM

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.

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.
A
arnholm@arnholm.org
Wed, May 6, 2015 12:25 PM

On 2015-05-06 00:31, jellsworth wrote:

  • Maybe there is a way to also accommodate the leading version control
    systems, or at least git. Now that would be a productive discussion!

I have used several version control systems.

OpenSCAD is no different than any other programming environment where
the user's code is stored in text files. OpenSCAD files are already
accommodated in any system like git, bazaar, subversion, hg, you name it
(perforce, etc. etc.). Personally I use Bazaar, but anything goes.

I don't think it is the responsibility of OpenSCAD to do anything in
this area.

Carsten Arnholm

On 2015-05-06 00:31, jellsworth wrote: > * Maybe there is a way to also accommodate the leading version control > systems, or at least git. Now that would be a productive discussion! I have used several version control systems. OpenSCAD is no different than any other programming environment where the user's code is stored in text files. OpenSCAD files are already accommodated in any system like git, bazaar, subversion, hg, you name it (perforce, etc. etc.). Personally I use Bazaar, but anything goes. I don't think it is the responsibility of OpenSCAD to do anything in this area. Carsten Arnholm
R
runsun
Wed, May 6, 2015 5:01 PM

Ivo wrote

With all this meta information available, it would be nice to get rid of
the "echo" in echo()

+100 !!

Ivo wrote

and be able to format stuff prettier. I'd like to be able to generate
openscad files in openscad.

My  OpenSCAD_DocTest lib https://github.com/runsun/openscad_doctest  can
write formatted code to the console. It's, in fact, making use of OpenSCAD's
own features. So OpenSCAD can do some type of formatting.

Recently I recoded my lib to be able to generate html page. See  here
http://doctestscad.runsun.info/doctest_tool_api.htm  for example. The
webpage is dynamic and entirely generated by OpenSCAD, including HTML, CSS
and Javascript. The only post-process I need is to get rid of the unwanted
"ECHO: ". (see my  python code
http://forum.openscad.org/Sharing-Dump-echo-output-to-a-file-td12529.html
for this purpose).

So it seems that OpenSCAD is already capable of doing what you want.

BTW, can you give an example usage of generating openscad files in openscad
?


$  Runsun Pan, PhD

$ -- OpenScad_DocTest: doc and unit test ( Github , Thingiverse  )

$ -- hash parameter model: here , here

$ -- Linux Mint 17.1 Rebecca x64  + OpenSCAD 2015.03.15/2015.04.01.nightly

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

Ivo wrote > With all this meta information available, it would be nice to get rid of > the "echo" in echo() +100 !! Ivo wrote > and be able to format stuff prettier. I'd like to be able to generate > openscad files in openscad. My OpenSCAD_DocTest lib <https://github.com/runsun/openscad_doctest> can write formatted code to the console. It's, in fact, making use of OpenSCAD's own features. So OpenSCAD can do some type of formatting. Recently I recoded my lib to be able to generate html page. See here <http://doctestscad.runsun.info/doctest_tool_api.htm> for example. The webpage is dynamic and entirely generated by OpenSCAD, including HTML, CSS and Javascript. The only post-process I need is to get rid of the unwanted "ECHO: ". (see my python code <http://forum.openscad.org/Sharing-Dump-echo-output-to-a-file-td12529.html> for this purpose). So it seems that OpenSCAD is already capable of doing what you want. BTW, can you give an example usage of generating openscad files in openscad ? ----- $ Runsun Pan, PhD $ -- OpenScad_DocTest: doc and unit test ( Github , Thingiverse ) $ -- hash parameter model: here , here $ -- Linux Mint 17.1 Rebecca x64 + OpenSCAD 2015.03.15/2015.04.01.nightly -- View this message in context: http://forum.openscad.org/new-Special-Variable-tp12579p12596.html Sent from the OpenSCAD mailing list archive at Nabble.com.
C
clothbot
Wed, May 6, 2015 7:03 PM

I'm ok with echo() behaving as it does for quick debug stuff.

I'd rather have an explicit, C++ style 'printf()' supported.  Devil's in the
details, but shouldn't be too difficult to implement using the echo() code
(most likely src file: src/control.cc) as a starting point.

Andrew.

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

I'm ok with echo() behaving as it does for quick debug stuff. I'd rather have an explicit, C++ style 'printf()' supported. Devil's in the details, but shouldn't be too difficult to implement using the echo() code (most likely src file: src/control.cc) as a starting point. Andrew. -- View this message in context: http://forum.openscad.org/new-Special-Variable-tp12579p12597.html Sent from the OpenSCAD mailing list archive at Nabble.com.
R
runsun
Wed, May 6, 2015 8:19 PM

I believe the requests about echo() are simply to have an option to turn off
the printing of "ECHO: ", which has no effect at all to those who don't need
it to be turned off.

The difference between that and the "printf()" is that, printf() can be
achieved by user function easily ( I can write one if needed), so having
openscad to include something like printf() is not that critical.

But the print out of "ECHO: " is something you can't overcome with user
function in openscad.


$  Runsun Pan, PhD

$ -- OpenScad_DocTest: doc and unit test ( Github , Thingiverse  )

$ -- hash parameter model: here , here

$ -- Linux Mint 17.1 Rebecca x64  + OpenSCAD 2015.03.15/2015.04.01.nightly

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

I believe the requests about echo() are simply to have an option to turn off the printing of "ECHO: ", which has no effect at all to those who don't need it to be turned off. The difference between that and the "printf()" is that, printf() can be achieved by user function easily ( I can write one if needed), so having openscad to include something like printf() is not that critical. But the print out of "ECHO: " is something you can't overcome with user function in openscad. ----- $ Runsun Pan, PhD $ -- OpenScad_DocTest: doc and unit test ( Github , Thingiverse ) $ -- hash parameter model: here , here $ -- Linux Mint 17.1 Rebecca x64 + OpenSCAD 2015.03.15/2015.04.01.nightly -- View this message in context: http://forum.openscad.org/new-Special-Variable-tp12579p12599.html Sent from the OpenSCAD mailing list archive at Nabble.com.
M
MichaelAtOz
Wed, May 6, 2015 9:23 PM

runsun wrote

Also, I'd like to have

$date

and

$now

.

OpenSCAD version is based on date,

I'm not sure what you were after, but there is version().


Unless specifically shown otherwise above, my contribution is in the Public Domain; To the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. This work is published globally via the internet. :) Inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.”  Fight it! http://www.ourfairdeal.org/

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

runsun wrote > Also, I'd like to have * > $date * > and * > $now * > . > > OpenSCAD version is based on date, I'm not sure what you were after, but there is version(). ----- Unless specifically shown otherwise above, my contribution is in the Public Domain; To the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. This work is published globally via the internet. :) Inclusion of works of previous authors is not included in the above. The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ -- View this message in context: http://forum.openscad.org/new-Special-Variable-tp12579p12600.html Sent from the OpenSCAD mailing list archive at Nabble.com.
R
runsun
Wed, May 6, 2015 10:23 PM

MichaelAtOz wrote

runsun wrote

Also, I'd like to have

$date

and

$now

.

OpenSCAD version is based on date,

I'm not sure what you were after, but there is version().

The current date and time when file is executed.


$  Runsun Pan, PhD

$ -- OpenScad_DocTest: doc and unit test ( Github , Thingiverse  )

$ -- hash parameter model: here , here

$ -- Linux Mint 17.1 Rebecca x64  + OpenSCAD 2015.03.15/2015.04.01.nightly

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

MichaelAtOz wrote > > runsun wrote >> Also, I'd like to have * >> $date * >> and * >> $now * >> . >> >> OpenSCAD version is based on date, > I'm not sure what you were after, but there is version(). The current date and time when file is executed. ----- $ Runsun Pan, PhD $ -- OpenScad_DocTest: doc and unit test ( Github , Thingiverse ) $ -- hash parameter model: here , here $ -- Linux Mint 17.1 Rebecca x64 + OpenSCAD 2015.03.15/2015.04.01.nightly -- View this message in context: http://forum.openscad.org/new-Special-Variable-tp12579p12601.html Sent from the OpenSCAD mailing list archive at Nabble.com.
J
jellsworth
Thu, May 7, 2015 2:03 AM

cacb wrote

On 2015-05-06 00:31, jellsworth wrote:

  • Maybe there is a way to also accommodate the leading version control
    systems, or at least git. Now that would be a productive discussion!

OpenSCAD is no different than any other programming environment where
the user's code is stored in text files. OpenSCAD files are already
accommodated in any system like git, bazaar, subversion, hg, you name it
(perforce, etc. etc.). Personally I use Bazaar, but anything goes.

I don't think it is the responsibility of OpenSCAD to do anything in
this area.

I agree with you, but I think I did not make my point clear. OpenSCAD
doesn't need to build in it's own version control system. What I liked was
the idea of providing a scad file /access/ to the version info so that it
could be expressed within the 3d model.

Regards,
Jerry E

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

cacb wrote > On 2015-05-06 00:31, jellsworth wrote: >> * Maybe there is a way to also accommodate the leading version control >> systems, or at least git. Now that would be a productive discussion! > > OpenSCAD is no different than any other programming environment where > the user's code is stored in text files. OpenSCAD files are already > accommodated in any system like git, bazaar, subversion, hg, you name it > (perforce, etc. etc.). Personally I use Bazaar, but anything goes. > > I don't think it is the responsibility of OpenSCAD to do anything in > this area. I agree with you, but I think I did not make my point clear. OpenSCAD doesn't need to build in it's own version control system. What I liked was the idea of providing a scad file /access/ to the version info so that it could be expressed within the 3d model. Regards, Jerry E -- View this message in context: http://forum.openscad.org/new-Special-Variable-tp12579p12602.html Sent from the OpenSCAD mailing list archive at Nabble.com.