parameterized export file name

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

parameterized export file name

dinther
Hi I am Paul, new to this forum. I use openSCAD for all my FDM 3D print designs and as such iterate through designs rapidly with changing parameters to get parts to fit just right.

For example: A shaft adapters external diameter needs to fit tightly in a wheel housing and the inside diameter must fit tightly around a motor shaft. Let's call the project "adapter.scad" with two parameters called od and an id

I render the project with od = 8.25 and id = 5.13 then export the STL file.

The default STL filename is the project name followed by ".stl" like "adapter.stl" and currently I manually rename it by adding the parameter values to the filename. eg: "adapter_8.25_5.13.scad"

This helps me a lot to keep track of what files worked. We could have arguments about version control and appropriate annotation but for my one man operation version control get's in the way. I read the thread about the proposed export() function and I understand the objections and risks.

What I think would be extremely helpful is the ability to define the filename or a suffix to the file name in code while the actual export action is only triggered by the UI as it is now. For example:

$suffix = str("_od", od, "_id", id);

Then, when I click on export STL the default filename will appear as "adapter_8.25_5.13.scad". I so hope I haven't missed anything in the manual that could be helpful for this but I am keen to hear how this can help.





Sent from the OpenSCAD mailing list archive at Nabble.com.

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

Re: parameterized export file name

JordanBrown
On 3/4/2021 8:25 PM, dinther wrote:
$suffix = str("_od", od, "_id", id);

Sounds reasonable to me.

Note that depending on your exact application, you may be able to achieve the same goals by wrapping a script around a non-interactive invocation of OpenSCAD.  If you know that you need six different ID/OD combinations, have a script invoke OpenSCAD six times, writing the resulting STL to six different output files.


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

Re: parameterized export file name

MichaelAtOz
Administrator
JordanBrown wrote
On 3/4/2021 8:25 PM, dinther wrote:
> $suffix = str("_od", od, "_id", id);

Sounds reasonable to me.
If this is done, it should probably conceptually include a prefix.

Some additional information would be useful to construct a filename:
- date
- time
- filename
- etc

Possibly from a function, say system(), e.g.
fn = system("filename");
dt = system("now"); // date-time

combine both into something like
$filename = str("prefix",fn, "_", dt,"_suffix");

There a many issues on GitHub asking for 'system' type information, e.g.
https://github.com/openscad/openscad/issues/339 -
https://github.com/openscad/openscad/issues/380 - includes my raving late night thoughts...
https://github.com/openscad/openscad/pull/2741 - proposed waiting for 'Objects'
https://github.com/openscad/openscad/issues/2755 - seem to be the continuing issue

My request for a more detailed version(), proposes a structured vector as the result of a version_info() function.
Such could be part of a larger structure combining version details and external info (date, time, etc).

v = system();

v is [ 
version - vector as below      // 0 - same struc as version() - support deprecation in future
  [year, month, day(zero for release & candidate)],
number,                        // 1 - same as version_num() - ditto
major,                         // 2 - text, yyyy.mm
minor,                         // 3 - text, yyyy.mm[.dd | "-"& release | "-RC"& release ]  e.g 2021.01.15, 2015.03-2,  2021.01-RC6
snapshot,                      // 4 - text, yyyy.mm[.dd | "-"& release | "-RC"& release] ".ci" & ci "(git " & git ")" 
release,                       // 5 - release number e.g. 6 (even for RC6)
is_release,                    // 6 - boolean - true for release and release candidate 
is_candidate,                  // 7 - boolean
ci,                            // 8 - as per info in snapshot (include for release)
git,                           // 9 - ditto
date,
time,
etc    
      ]

But that is getting unwieldy, so maybe it returns subsets
v=system("version");
dt=system("date-time");

OK, I'll stop here.
OpenSCAD Admin - email* me if you need anything, or if I've done something stupid...
* on the Forum, 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.


Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
OpenSCAD Admin - email* me if you need anything, or if I've done something stupid...
* on the Forum, 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.
Reply | Threaded
Open this post in threaded view
|

Re: parameterized export file name

JordanBrown
On 3/5/2021 8:27 PM, MichaelAtOz wrote:
JordanBrown wrote
On 3/4/2021 8:25 PM, dinther wrote:
> $suffix = str("_od", od, "_id", id);

Sounds reasonable to me.
If this is done, it should probably conceptually include a prefix.

Since it's only a suggestion, a default for a following "Export as", perhaps it can be the entire suggested name.  Probably less file type, to be filled in by the selected "Export as".  Probably not allowing directories.

Some additional information would be useful to construct a filename:
- date
- time
- filename
- etc

Possibly from a function, say system(), e.g.

<bikeshed>
Sounds like a fine idea, but I would use a different name.  You said system(something) and my mind immediately went to the C library system() function, which executes another program.
</bikeshed>


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

Re: parameterized export file name

dinther
Well, we are using a programming language so I figure since the user still initiates the export and confirms the file name, the feature might as well allow full definition in code and not just a suffix. That keeps clutter to a minimum and we can juggle what ever data we want into the file name.

Sent from the OpenSCAD mailing list archive at Nabble.com.

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

Re: parameterized export file name

OpenSCAD mailing list-2
Agreed, and I'd like to see that logic extended to text files as well.


-----Original Message-----
From: dinther <[hidden email]>
To: [hidden email]
Sent: Tue, Mar 9, 2021 12:00 am
Subject: Re: [OpenSCAD] parameterized export file name

Well, we are using a programming language so I figure since the user still initiates the export and confirms the file name, the feature might as well allow full definition in code and not just a suffix. That keeps clutter to a minimum and we can juggle what ever data we want into the file name.

Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
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: parameterized export file name

JordanBrown
On 3/9/2021 7:21 PM, William F. Adams via Discuss wrote:
Agreed, and I'd like to see that logic extended to text files as well.

Text files don't have an "export" mechanism that the user invokes and confirms.

In my earlier comments, I was thinking of the interactive "export" operation.  I don't know how this hypothetical feature would interact with command-line usage, or if it should.


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