Quantcast

Writing to files?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Writing to files?

Troberg
Today, I have two ways I do my scripts:

1. Use a program I've written to generate the scripts from Excel, where I do my calculations. This makes for awkward script programming when I want to do something complicated, but it allows me to use the measurements as input for a parts list when I'm going to buy stuff when building the object.

2. Use Excel to simply generate a few seed measurements variables into a script which I include in the main script, then script normally and do the calculations in the script. Neater scripting, but doesn't allow me to export the calculated values in a sample way, so I can't generate the parts lists.

I would like to work according to #2, but that would require duplicating a lot of calculations (with all the errors that'll bring). However, if there was a simple way to export some variables, it would be doable.

Basically, something like (for example):

writefile("c:\temp\myfile.txt", myvar); //Appends variable to file, creating the file if needed
writefile("c:\temp\myfile.txt", myothervar);

Which would result in (assuming values 1 and 2):

myvar=1
myothervar=2

This, of course, would be easy to handle in further processing stages.

Of course, some command to delete a file would also be needed.

Basically, OpenSCAD is great when it works alone, but when you have to put it in a larger process, some means of connecting things together is needed.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Writing to files?

nophead
I just use echo and then post process the output with python.

On 23 March 2017 at 11:48, Troberg <[hidden email]> wrote:
Today, I have two ways I do my scripts:

1. Use a program I've written to generate the scripts from Excel, where I do
my calculations. This makes for awkward script programming when I want to do
something complicated, but it allows me to use the measurements as input for
a parts list when I'm going to buy stuff when building the object.

2. Use Excel to simply generate a few seed measurements variables into a
script which I include in the main script, then script normally and do the
calculations in the script. Neater scripting, but doesn't allow me to export
the calculated values in a sample way, so I can't generate the parts lists.

I would like to work according to #2, but that would require duplicating a
lot of calculations (with all the errors that'll bring). However, if there
was a simple way to export some variables, it would be doable.

Basically, something like (for example):

writefile("c:\temp\myfile.txt", myvar); //Appends variable to file, creating
the file if needed
writefile("c:\temp\myfile.txt", myothervar);

Which would result in (assuming values 1 and 2):

myvar=1
myothervar=2

This, of course, would be easy to handle in further processing stages.

Of course, some command to delete a file would also be needed.

Basically, OpenSCAD is great when it works alone, but when you have to put
it in a larger process, some means of connecting things together is needed.



--
View this message in context: http://forum.openscad.org/Writing-to-files-tp21005.html
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
|  
Report Content as Inappropriate

Re: Writing to files?

Troberg
Is there a way to redirect the echo output to a file, or do I have to do the copy-paste dance?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Writing to files?

MichaelAtOz
Administrator
If you are using the GUI, the later.
You could try the command line.
Admin - PM me if you need anything,
or if I've done something stupid...

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!
Loading...