
OpenSCAD .csv driven batch exporter
Description
Here Is A Python Script That Will Execute A Batch Series Of Openscad Command Lines Driven From A .Csv File. You Can Use It To Generate A Set Of Images, A Set Of .Stls Or Whatever Formats Are Now Or Future Supported. It Uses Openscad'S -D Capability To Populate Variables On The Command Line. Since Openscad Determines The Output Format From The Extension Of The Output Filename, That Is Driven From The .Csv As Well. The .Csv Would Would Like This: File,Args,Able, Baker, Charlie "Test1.Png","--Render --Projection=O",10,20,30 "Test2.Stl",,20,30,40 "Test3.Stl",,30,40,50 For An Openscad File Like This: Able = 10; Baker= 10; Charlie = 10; Cube([Able,Baker,Charlie]); On Debian, The Command Python3 Openscad_Batch.Py -X Params.Csv Test.Scad Would Generate (And Optionally Execute If The -X Was Missing,) A Series Of Command Lines Like This: * Openscad --Render --Projection=O -D "Baker=20" -D "Able=10" -D "Charlie=30" -O Test1.Png Test.Scad * Openscad -D "Baker=30" -D "Able=20" -D "Charlie=40" -O Test2.Stl Test.Scad * Openscad -D "Baker=40" -D "Able=30" -D "Charlie=50" -O Test3.Stl Test.Scad Notes: - It'S Python 3 (Sorry, But I'Ve Moved On. 3 Is The Future.) - It Needs A Recent Version Of Openscad To Be Able To Do Things Like Render (See Openscad Docs For A List Of Which Command Line Switches Each Version Of Openscad Supports. - Call It With -H To Get Instructions (You Can Also Read Them In The Source Below - I'Ve Tested On Windows 8.1 And Debian 64 Bit Here'S The Help It Generates: ----------------------------------------------------------- ``` Usage: Openscad_Batch.Py [-H] [-X] Csv Openscad_File Run Openscad Repeatedly With Parameters Driven From A .Csv File. ---------- Usage Notes ---------------- * First _Row_ Of .Csv Contains Paramter Names (I.E. Openscad Constants) Note: Do Not Enclose Parameter Names In Quotes. * First _Column_ Of First _Row_ Must Be Named File. * First _Column_ Of Subsequent Rows Must Contain Output File Name For That Row'S Values And Be In Double Quotes (E.G. "Cube1.Stl") * Second _Column_ Of First _Row_ Must Be Named Args * Second _Column_ Of Subsequent Rows Must Contain Openscad Cmd Line Args For That File Output Or Be Empty (E.G. ,"--Render", For A .Png Output Or ,, For A Line With No Args) * String Values In Subsequent Rows Must Be Enclosed In Double Quotes. * Openscad Executable Must Be In The Path Positional Arguments: Csv Location Of .Csv File Containing Params Openscad_File Name Of Openscad File (Without Args) Optional Arguments: -H, --Help Show This Help Message And Exit -X Don'T Execute Command Line (Just Send Output To Console) Example Commands: C:Python34Python Openscad_Batch.Py Params.Csv Cubeout.Scad Python Openscad_Batch.Py -X Params.Csv Cubeout.Scad (Linux) Python3 Openscad_Batch.Py Params.Csv Cubeout.Scad Example .Csv File: File,Args,Able,Baker,Charlie "Cube1.Png","--Render",10,20,30 "Cube2.Stl",,20,30,40 "Cube3.Stl",,30,40,50 Works With .Scad File: Able = 10; Baker= 10; Charlie = 10; Cube([Able,Baker,Charlie]); ```
Statistics
Likes
16
Downloads
0