batch processing commands

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

batch processing commands

ufomorace
I want to process a list of .scad files in a folder, and i didn't understand how to do it with command line, please could someone tell me the secret codes?
Reply | Threaded
Open this post in threaded view
|

Re: batch processing commands

G. Wade Johnson
On Sat, 19 Sep 2015 14:37:34 -0700 (MST)
ufomorace <[hidden email]> wrote:

> I want to process a list of .scad files in a folder, and i didn't
> understand how to do it with command line, please could someone tell
> me the secret codes?

The simplest of commands for one file would be:

   openscad -o file.stl file.scad

You could repeat this using whatever looping construct is available in
your shell. (For windows, it's been so long I can't remember the
syntax.) For bash, you could do

for f in *.scad; do openscad -o ${f/scad/stl} $f; done

Personally, I use a Makefile with an appropriate rule for converting
any .scad file into a .stl.

%.stl: %.scad
        $(OPENSCAD) -o $@ $<

HTH,
G. Wade
--
A development process that involves any amount of tedium will
eventually be done poorly or not at all.
                -- Matt Blodgett's First Law of Software Development

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

Re: batch processing commands

ufomorace
Thanks, i will figure it out and i will write it on the wiki if i can.

Ant
Reply | Threaded
Open this post in threaded view
|

Re: batch processing commands

bobc
If it helps, equivalent in a Windows batch fiile is :

for %%f in (*.scad) do echo openscad -o %%~nf.stl %%f

Reply | Threaded
Open this post in threaded view
|

Re: batch processing commands

bobc
That should be

for %%f in (*.scad) do openscad -o %%~nf.stl %%f

of course.
Reply | Threaded
Open this post in threaded view
|

Re: batch processing commands

ufomorace
oh my god awesome. i will write that to the wiki and to various resources. i was going to take at least an hour of learning a new code to find that line \8D/
Reply | Threaded
Open this post in threaded view
|

Re: batch processing commands

ufomorace
I'll change to a new email soon, save from the pop routing errors.

in the end i had a .bat file with text:
for %%f in (*.scad) do openscad -o %%~nf.stl %%f

written in it, and i had to set the PATH using this else it didnt recognize openscad:

*** GUIDE FOR SETTING WINDOWS PATH ENTRIES FOR CMD.EXE:***
Start the System Control Panel applet (Start - Settings - Control Panel - System).
Select the Advanced tab.
Click the Environment Variables button.
Under System Variables, select Path, then click Edit.
You'll see a list of folders, as this example for my system shows: C:\Program Files\Windows Resource Kits\Tools\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Support Tools\;C:\Program Files\Common Files\Roxio Shared\DLLShared;C:\Program Files\Common Files\Ulead Systems\MPEG;C:\Program Files\Intel\DMIX;C:\Program Files\Executive Software\Diskeeper\;C:\Program Files\Bonjour\;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\Misc
You can add additional folders that you want to include in searches. I add a "C:\program files\misc" entry into which I place my standalone utilities, instead of copying them into C:\windows. Click OK.
You'll need to restart the processes (e.g., command prompt) that use the system path to see the added folders.
Reply | Threaded
Open this post in threaded view
|

Re: batch processing commands

ufomorace
This post was updated on .
I ran the command on some files from kit wallace's website for a test and about 1/3rd of the .scad files were processed.

So i ran it on a couple of dozen of my .scad files and only 1/20 files was processed. If i run the program without the -o command, it opens 20 windows at once, all of them have empty code windows except for one of them that had one line of code in it.

Reply | Threaded
Open this post in threaded view
|

Re: batch processing commands

ufomorace
This post was updated on .
ok it seems like it's working although perhaps it's not totally there, here is what i did:

had to rename all the files with spaces " " to "_"  because cmd.exe didn't see them,

to do that:  

1/ run powershell.exe from system3d/windowspowershell or just the run console
2/ type cd "D:\my dir\batch dir"
3/ do this powershell command:   Dir | Rename-Item –NewName { $_.name –replace “ “,”_” }
4/ then run the script from a .bat file... FOR %%f in (*.scad)  DO openscad -o %%~nf.stl %%f

we can also write batch files from powershell for windows it's the new cmd.exe since 2009 it has more flexibility and more ledgible, but it's still an entirely new code so only for those who want to learn powershell syntax.


Reply | Threaded
Open this post in threaded view
|

Re: batch processing commands

Shaporev, Timur
You can put file names in double quotes for spaces and the like,
but I strongly recommend make.

Just my $0.02
________________________________________
From: Discuss [[hidden email]] on behalf of ufomorace [[hidden email]]
Sent: 22 September 2015 10:41
To: [hidden email]
Subject: Re: [OpenSCAD] batch processing commands

ok it seems like it's working although perhaps it's not totally there, here
is what i did:

had to rename all the files with spaces " " to "_"  because cmd.exe didn't
see them,

to do that:

1/ run powershell.exe from system3d/windowspowershell or just the run
console
2/ type cd "D:\my dir\batch dir"
3/ do this powershell command:   Dir | Rename-Item –NewName { $_.name
–replace “ “,”_” }
4/ then run the script from a .bat file... FOR %%f in (*.scad)  DO openscad
-o %%_nf.stl %%f

we can also write batch files from powershell for windows it's the new
cmd.exe since 2009 it has more flexibility and more ledgible, but it's still
an entirely new code so only for those who want to learn powershell syntax.






--
View this message in context: http://forum.openscad.org/batch-processing-commands-tp13918p13953.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
|

Re: batch processing commands

ufomorace
the files would be in a double quotes with a wild card in the current directory, i don't know if i can write "%THIS_DIR%*.scad" kind of directory so that the batch file can run on any pc and be a portable windows option for batch processing scads, for others too, that's the intention. anyways it works, will see if cmd.exe crashes after 10 files or something, quite possible. i am after a one click solution for others and myself, not learning powershell, batch, and makefile just so that i can make my slow scad files :)
Reply | Threaded
Open this post in threaded view
|

Re: batch processing commands

nophead
In reply to this post by Shaporev, Timur
Better to use Python than shell scripts as they are simpler and more readable and run on any OS.

On 22 September 2015 at 09:03, Shaporev, Timur <[hidden email]> wrote:
You can put file names in double quotes for spaces and the like,
but I strongly recommend make.

Just my $0.02
________________________________________
From: Discuss [[hidden email]] on behalf of ufomorace [[hidden email]]
Sent: 22 September 2015 10:41
To: [hidden email]
Subject: Re: [OpenSCAD] batch processing commands

ok it seems like it's working although perhaps it's not totally there, here
is what i did:

had to rename all the files with spaces " " to "_"  because cmd.exe didn't
see them,

to do that:

1/ run powershell.exe from system3d/windowspowershell or just the run
console
2/ type cd "D:\my dir\batch dir"
3/ do this powershell command:   Dir | Rename-Item –NewName { $_.name
–replace “ “,”_” }
4/ then run the script from a .bat file... FOR %%f in (*.scad)  DO openscad
-o %%_nf.stl %%f

we can also write batch files from powershell for windows it's the new
cmd.exe since 2009 it has more flexibility and more ledgible, but it's still
an entirely new code so only for those who want to learn powershell syntax.






--
View this message in context: http://forum.openscad.org/batch-processing-commands-tp13918p13953.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


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

Re: batch processing commands

bobc
In reply to this post by ufomorace
No need to rename files, just use:

FOR %%f in (*.scad)  DO openscad -o "%%_nf.stl" "%%f"

make and python are great if you already have them installed, but overkill in this case.
Reply | Threaded
Open this post in threaded view
|

Re: batch processing commands

G. Wade Johnson
In reply to this post by Shaporev, Timur
+1

On 2015-09-22 03:03, Shaporev, Timur wrote:

> You can put file names in double quotes for spaces and the like,
> but I strongly recommend make.
>
> Just my $0.02
> ________________________________________
> From: Discuss [[hidden email]] on behalf of
> ufomorace [[hidden email]]
> Sent: 22 September 2015 10:41
> To: [hidden email]
> Subject: Re: [OpenSCAD] batch processing commands
>
> ok it seems like it's working although perhaps it's not totally there,
> here
> is what i did:
>
> had to rename all the files with spaces " " to "_"  because cmd.exe
> didn't
> see them,
>
> to do that:
>
> 1/ run powershell.exe from system3d/windowspowershell or just the run
> console
> 2/ type cd "D:\my dir\batch dir"
> 3/ do this powershell command:   Dir | Rename-Item –NewName { $_.name
> –replace “ “,”_” }
> 4/ then run the script from a .bat file... FOR %%f in (*.scad)  DO
> openscad
> -o %%_nf.stl %%f
>
> we can also write batch files from powershell for windows it's the new
> cmd.exe since 2009 it has more flexibility and more ledgible, but it's
> still
> an entirely new code so only for those who want to learn powershell
> syntax.
>
>
>
>
>
>
> --
> View this message in context:
> http://forum.openscad.org/batch-processing-commands-tp13918p13953.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


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

Re: batch processing commands

Tim V. Shaporev
In reply to this post by bobc
make intended to save time and it may really save lot of time in some
situations.

On 22.09.2015 13:33, bobc wrote:

> No need to rename files, just use:
>
> FOR %%f in (*.scad)  DO openscad -o "%%_nf.stl" "%%f"
>
> make and python are great if you already have them installed, but overkill
> in this case.
>
>
>
> --
> View this message in context: http://forum.openscad.org/batch-processing-commands-tp13918p13957.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
tp3
Reply | Threaded
Open this post in threaded view
|

Re: batch processing commands

tp3
> make intended to save time and it may really save lot of time in some
> situations.
>
Yes, although that only works if make knows about all the dependencies.
Otherwise a simple Makefile will only work when changing the top level
scad file.

In theory OpenSCAD can write the dependency information to make it work
in the general case, but I've never tried that yet.

ciao,
  Torsten.

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

Re: batch processing commands

Tim V. Shaporev
I used to write dependencies manually :-)

On 22.09.2015 17:26, Torsten Paul wrote:

>> make intended to save time and it may really save lot of time in some
>> situations.
>>
> Yes, although that only works if make knows about all the dependencies.
> Otherwise a simple Makefile will only work when changing the top level
> scad file.
>
> In theory OpenSCAD can write the dependency information to make it work
> in the general case, but I've never tried that yet.
>
> ciao,
>    Torsten.
>
> _______________________________________________
> 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: batch processing commands

alexgibson
Could you describe your new workflow with batch processing Tim?  I have been
busy with complicated projects in OpenSCAD and have come up with a workflow
that makes sense to me, but I am keen to learn any real programmers' best
practice.

I currently have a split like this:

1) Library files I use all the time in 3 groups:
        SCAD I have made
        SCAD I have borrowed from others :)
        STLS
2) Global parameters file, which contains:
        Include/use commands to bring in the above
        All my project specific measurements
        Tolerance/Fudge factors
        variables I may change
3) Sub-assembly files
        Intermediate calculated parameters
        Modules for each component in the sub-assembly
        2D rendering for any laser cut parts
4) Final assembly
        Include files for the components above
        Call the modules from the sub-assemblies, in colour where
appropriate.

Any comments or suggestions on this, and how I could fit in batch processing
where I need it?

Cheers,
Alex

-----Original Message-----
From: Discuss [mailto:[hidden email]] On Behalf Of Tim
V. Shaporev
Sent: 22 September 2015 16:03
To: [hidden email]
Subject: Re: [OpenSCAD] batch processing commands

I used to write dependencies manually :-)

On 22.09.2015 17:26, Torsten Paul wrote:

>> make intended to save time and it may really save lot of time in some
>> situations.
>>
> Yes, although that only works if make knows about all the dependencies.
> Otherwise a simple Makefile will only work when changing the top level
> scad file.
>
> In theory OpenSCAD can write the dependency information to make it
> work in the general case, but I've never tried that yet.
>
> ciao,
>    Torsten.
>
> _______________________________________________
> 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


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

Re: batch processing commands

Tim V. Shaporev
To be frank, I am just making analogy with C language workflow:
i.e. output .stl file depends on the relevant .scad file AND all its
dependencies - I guess the dependencies list includes the global
parameters file, include files, imported .stl-s and the like.
If that .stl should be generated with the same makefile earlier - this
is Ok, make can handle it.

I am not aware about details of your current workflow to say something
more detailed :-(


On 22.09.2015 18:13, Alex Gibson wrote:

> Could you describe your new workflow with batch processing Tim?  I have been
> busy with complicated projects in OpenSCAD and have come up with a workflow
> that makes sense to me, but I am keen to learn any real programmers' best
> practice.
>
> I currently have a split like this:
>
> 1) Library files I use all the time in 3 groups:
> SCAD I have made
> SCAD I have borrowed from others :)
> STLS
> 2) Global parameters file, which contains:
> Include/use commands to bring in the above
> All my project specific measurements
> Tolerance/Fudge factors
> variables I may change
> 3) Sub-assembly files
> Intermediate calculated parameters
> Modules for each component in the sub-assembly
> 2D rendering for any laser cut parts
> 4) Final assembly
> Include files for the components above
> Call the modules from the sub-assemblies, in colour where
> appropriate.
>
> Any comments or suggestions on this, and how I could fit in batch processing
> where I need it?
>
> Cheers,
> Alex
>
> -----Original Message-----
> From: Discuss [mailto:[hidden email]] On Behalf Of Tim
> V. Shaporev
> Sent: 22 September 2015 16:03
> To: [hidden email]
> Subject: Re: [OpenSCAD] batch processing commands
>
> I used to write dependencies manually :-)
>
> On 22.09.2015 17:26, Torsten Paul wrote:
>>> make intended to save time and it may really save lot of time in some
>>> situations.
>>>
>> Yes, although that only works if make knows about all the dependencies.
>> Otherwise a simple Makefile will only work when changing the top level
>> scad file.
>>
>> In theory OpenSCAD can write the dependency information to make it
>> work in the general case, but I've never tried that yet.
>>
>> ciao,
>>     Torsten.
>>
>> _______________________________________________
>> 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
>
>
> _______________________________________________
> 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: batch processing commands

Stefan Peter
In reply to this post by Tim V. Shaporev
On 22.09.2015 14:25, Tim V. Shaporev wrote:
> make intended to save time and it may really save lot of time in some
> situations.

Beware, make can act strange when fed with paths or file names
containing blanks, non-ASCII characters  or reserved characters like
ampersands or braces. This problem seems to be worse when using make on
non unix systems, btw. In hugin (http://hugin.sourceforge.net/), make
has been used for generating panoramas from multiple input images, but
it had to be replaced with a processor of our own in order to overcome
these problems.

With kind regards

Stefan Peter



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

me.vcf (150 bytes) Download Attachment
12