new "Special Variable"?

classic Classic list List threaded Threaded
23 messages Options
12
Reply | Threaded
Open this post in threaded view
|

new "Special Variable"?

yvette
hi,

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

like, say, $fileName?  or $fileNameArray?

i don't know if you can build more than one input file at a time; all my
.scad files are "one file per thing being built".  i do use <include>
and <use>, but only one input file.  so if only one input file can be
built, then $fileName is more appropriate; if multiple input files can
be built, then $fileNameArray is more appropriate.

yes?  non?  eh?

rationale:

in each piece i build i stomp an "Engineering Change" (ec) level, along
with the version.

e.g., a build file for ec0 might be named:  wondafulWidget_003.scad

so i stomp "ec0_003" in the item being built; makes it easier to trace
"what made this thing?" issues.

now i have to manually change the write() that stomps the ec tag.  while
i'm not complaining about the workload (!), nonetheless, i've forgotten
to change the string in the write() several times when i do a "Save As".
  ex:  Save As "wondafulWidget_004.scad" has the item being built still
stomped with "ec_003".  <big sigh>  a good waste of time, carbon, and ABS!

with the $fileName special variable, i can substring to the version,
glom the version into a variable, and stomp the variable.  that ends any
confusion as to "what made what".

thanks for listening!
yvette

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: new "Special Variable"?

drxenocide
I'm not sure about a special variable, but it would be great if there were any kind of version control. Like one that would count how many times you hit save, and another one that counted renders.

So each time I hit save and render, it would make a new version number.

e.g. if I have a file called widget, if I have saved it once, and rendered 6 times since that save, it would be automatically saved as e.g. widget.v1.06 when I hit render. It would also be nice if you could choose to compress the folder with all of these saves from OpenSCAD.

Or am I really just describing a program that could manage all of this for me outside of OpenSCAD?

On Tue, May 5, 2015 at 11:31 AM, Yvette S. Hirth, CCP, CDP <[hidden email]> wrote:
hi,

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

like, say, $fileName?  or $fileNameArray?

i don't know if you can build more than one input file at a time; all my .scad files are "one file per thing being built".  i do use <include> and <use>, but only one input file.  so if only one input file can be built, then $fileName is more appropriate; if multiple input files can be built, then $fileNameArray is more appropriate.

yes?  non?  eh?

rationale:

in each piece i build i stomp an "Engineering Change" (ec) level, along with the version.

e.g., a build file for ec0 might be named:  wondafulWidget_003.scad

so i stomp "ec0_003" in the item being built; makes it easier to trace "what made this thing?" issues.

now i have to manually change the write() that stomps the ec tag.  while i'm not complaining about the workload (!), nonetheless, i've forgotten to change the string in the write() several times when i do a "Save As".  ex:  Save As "wondafulWidget_004.scad" has the item being built still stomped with "ec_003".  <big sigh>  a good waste of time, carbon, and ABS!

with the $fileName special variable, i can substring to the version, glom the version into a variable, and stomp the variable.  that ends any confusion as to "what made what".

thanks for listening!
yvette

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: new "Special Variable"?

G. Wade Johnson
I use a real version control system for this (currently, git) But then,
I'm a programmer, so version control makes sense.

Every system I've used in the past with special names or strings built
in to the text has failed because of the extra, independent manual
process of updating it.

So I use a tool built for that purpose.

On Tue, 5 May 2015 13:08:05 -0400
Ari Diacou <[hidden email]> wrote:

> I'm not sure about a special variable, but it would be great if there
> were any kind of version control. Like one that would count how many
> times you hit save, and another one that counted renders.
>
> So each time I hit save and render, it would make a new version
> number.
>
> e.g. if I have a file called widget, if I have saved it once, and
> rendered 6 times since that save, it would be automatically saved as
> e.g. widget.v1.06 when I hit render. It would also be nice if you
> could choose to compress the folder with all of these saves from
> OpenSCAD.
>
> Or am I really just describing a program that could manage all of
> this for me outside of OpenSCAD?
>
> On Tue, May 5, 2015 at 11:31 AM, Yvette S. Hirth, CCP, CDP <
> [hidden email]> wrote:
>
> > hi,
> >
> > any way we can get the filename(s) being built stuffed into a
> > special variable?
> >
> > like, say, $fileName?  or $fileNameArray?
> >
> > i don't know if you can build more than one input file at a time;
> > all my .scad files are "one file per thing being built".  i do use
> > <include> and <use>, but only one input file.  so if only one input
> > file can be built, then $fileName is more appropriate; if multiple
> > input files can be built, then $fileNameArray is more appropriate.
> >
> > yes?  non?  eh?
> >
> > rationale:
> >
> > in each piece i build i stomp an "Engineering Change" (ec) level,
> > along with the version.
> >
> > e.g., a build file for ec0 might be named:  wondafulWidget_003.scad
> >
> > so i stomp "ec0_003" in the item being built; makes it easier to
> > trace "what made this thing?" issues.
> >
> > now i have to manually change the write() that stomps the ec tag.
> > while i'm not complaining about the workload (!), nonetheless, i've
> > forgotten to change the string in the write() several times when i
> > do a "Save As".  ex: Save As "wondafulWidget_004.scad" has the item
> > being built still stomped with "ec_003".  <big sigh>  a good waste
> > of time, carbon, and ABS!
> >
> > with the $fileName special variable, i can substring to the
> > version, glom the version into a variable, and stomp the variable.
> > that ends any confusion as to "what made what".
> >
> > thanks for listening!
> > yvette
> >
> > _______________________________________________
> > OpenSCAD mailing list
> > [hidden email]
> > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
> >


--
Doing nothing is very hard to do … you never know when you’re finished.
                                                   -- Leslie Nielsen

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: new "Special Variable"?

yvette
On 05/05/2015 11:33 AM, G. Wade Johnson wrote:

> I use a real version control system for this (currently, git) But then,
> I'm a programmer, so version control makes sense.

well gee gosh, i've been a programmer since 1967, i.e., for 48 years,
and personally, i loathe version control systems.

> Every system I've used in the past with special names or strings built
> in to the text has failed because of the extra, independent manual
> process of updating it.

which is what i'm trying to avoid.

> So I use a tool built for that purpose.

you use the tool you want; i'll use the tool i want.

also, for ec/code stamping of large, complicated products with lots to
engineer, one could stomp the entire filename into a piece.  can't do
that with version control.

yvette


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: new "Special Variable"?

Michele
On 05-05-2015 3:08 PM, Yvette S. Hirth, CCP, CDP wrote:
> On 05/05/2015 11:33 AM, G. Wade Johnson wrote:
>
>> I use a real version control system for this (currently, git) But then,
>> I'm a programmer, so version control makes sense.
>
> well gee gosh, i've been a programmer since 1967, i.e., for 48 years,
> and personally, i loathe version control systems.

Well you've got me beat by five years but I agree 100% with you.  This
is just a bad idea that Openscad doesn't need.

             - Michele



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: new "Special Variable"?

G. Wade Johnson
In reply to this post by yvette
On Tue, 05 May 2015 12:08:29 -0700
"Yvette S. Hirth, CCP, CDP" <[hidden email]> wrote:

> On 05/05/2015 11:33 AM, G. Wade Johnson wrote:
>
> > I use a real version control system for this (currently, git) But
> > then, I'm a programmer, so version control makes sense.
>
> well gee gosh, i've been a programmer since 1967, i.e., for 48 years,
> and personally, i loathe version control systems.

Sorry to hear that they don't work for you. I made the comment mostly
because not all OpenSCAD users are programmers and it has been an issue
before.

I meant it as an explanation for my usage, not to be condescending.

> > Every system I've used in the past with special names or strings
> > built in to the text has failed because of the extra, independent
> > manual process of updating it.
>
> which is what i'm trying to avoid.
>
> > So I use a tool built for that purpose.
>
> you use the tool you want; i'll use the tool i want.
>
> also, for ec/code stamping of large, complicated products with lots
> to engineer, one could stomp the entire filename into a piece.  can't
> do that with version control.

I just hate working with systems where there are a whole bunch of
copies of the same code with slightly different filenames. But, if it
works for you, I'm happy it works.

G. Wade

> yvette
>
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


--
A 'language' is a dialect with an army.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: new "Special Variable"?

yvette
On 05/05/2015 12:33 PM, G. Wade Johnson wrote:

> I just hate working with systems where there are a whole bunch of
> copies of the same code with slightly different filenames. But, if it
> works for you, I'm happy it works.

thank you for that!
yvette

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: new "Special Variable"?

jellsworth
In reply to this post by G. Wade Johnson
My opinion(s), fwiw:

* I love the idea of stamping a version label directly into the 3d model, even though this would only make sense for a few types of models. The filename-variable suggestion is nice, simple way to do it.

* Yes, a real version control system is a powerful way to manage your files. If that works for you, use it! If not, don't!

* The problem here is that this clever approach leaves the version control users out in the cold, if they can only stamp their models based on filename.

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

Regards,
Jerry E
Reply | Threaded
Open this post in threaded view
|

Re: new "Special Variable"?

MichaelAtOz
Administrator
In reply to this post by yvette
Issue 380
Admin - email* me if you need anything,
or if I've done something stupid...
* click on my MichaelAtOz label, there is a link to email me.

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.
Obviously 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/ time is running out!
Reply | Threaded
Open this post in threaded view
|

Re: new "Special Variable"?

Len Trigg
In reply to this post by jellsworth

On 6 May 2015 at 10:31, jellsworth <[hidden email]> wrote:
* The problem here is that this clever approach leaves the version control
users out in the cold, if they can only stamp their models based on
filename.

You can pass variables in from outside by using the -D parameter to openscad. Yvette could thus use a workaround wrapper script when launching openscad that sets a variable to the current filename. In linux this would look something like:

if [ "$1" ]; then
  openscad -D fileName=$(basename $1) $1
else
  openscad
fi

Similarly, if you have your files under version control you could substitute the output of git describe as your version tag.

Cheers,
Len.



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: new "Special Variable"?

jellsworth
Nice!

Thanks,
Jerry E
Reply | Threaded
Open this post in threaded view
|

Re: new "Special Variable"?

runsun
In reply to this post by yvette
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
$ libs: scadx, doctest, faces(git), offline doc(git), runscad.py(2,git), editor of choice: CudaText ( OpenSCAD lexer); $ Tips; $ Snippets
Ivo
Reply | Threaded
Open this post in threaded view
|

Re: new "Special Variable"?

Ivo

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.

Reply | Threaded
Open this post in threaded view
|

Re: new "Special Variable"?

cacb
In reply to this post by jellsworth
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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: new "Special Variable"?

runsun
In reply to this post by Ivo
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 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 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 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
$ libs: scadx, doctest, faces(git), offline doc(git), runscad.py(2,git), editor of choice: CudaText ( OpenSCAD lexer); $ Tips; $ Snippets
Reply | Threaded
Open this post in threaded view
|

Re: new "Special Variable"?

clothbot
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.
Reply | Threaded
Open this post in threaded view
|

Re: new "Special Variable"?

runsun
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
$ libs: scadx, doctest, faces(git), offline doc(git), runscad.py(2,git), editor of choice: CudaText ( OpenSCAD lexer); $ Tips; $ Snippets
Reply | Threaded
Open this post in threaded view
|

Re: new "Special Variable"?

MichaelAtOz
Administrator
In reply to this post by runsun
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().
Admin - email* me if you need anything,
or if I've done something stupid...
* click on my MichaelAtOz label, there is a link to email me.

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.
Obviously 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/ time is running out!
Reply | Threaded
Open this post in threaded view
|

Re: new "Special Variable"?

runsun
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
$ libs: scadx, doctest, faces(git), offline doc(git), runscad.py(2,git), editor of choice: CudaText ( OpenSCAD lexer); $ Tips; $ Snippets
Reply | Threaded
Open this post in threaded view
|

Re: new "Special Variable"?

jellsworth
In reply to this post by cacb
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
12