Permalink
Browse files

Initial add of OpenSCAD wrapper and test code. Set OpenSCADTestMode=1…

… to enable simple test.
  • Loading branch information...
1 parent 08d9459 commit 4f8973bc66033c73ed6f8a8c49f78c2762a1b435 @clothbot clothbot committed Aug 21, 2010
Showing with 75 additions and 1 deletion.
  1. +58 −0 OpenSCAD.pde
  2. +17 −1 SuperSkein.pde
View
58 OpenSCAD.pde
@@ -0,0 +1,58 @@
+// OpenSCAD Wrapper Functions.
+
+class OpenSCAD {
+
+ String execPath;
+ String execArgs;
+ String inputFile;
+ String outputType;
+ String outputFile;
+
+ OpenSCAD() {
+ execPath="/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD";
+ execArgs="-D render_select=0 -D slice_index=0";
+ outputType=DXF;
+ outputFile="output.dxf";
+ }
+
+ OpenSCAD(String iexecPath, String iexecArgs) {
+ execPath=iexecPath;
+ execArgs=iexecArgs;
+ }
+
+ void setInput(String iinputFile) { inputFile=iinputFile; }
+ void setExecArgs(String iexecArgs) { execArgs=iexecArgs; }
+ void setExecPath(String iexecPath) { execPath=iexecPath; }
+ void setOutput(String ioutputType, String ioutputFile) {
+ if( ioutputType==DXF ) {
+ outputType=ioutputType;
+ outputFile=ioutputFile;
+ }
+ }
+ String getInput() { return(inputFile); }
+ String getExecArgs() { return(execArgs); }
+ String getExecPath() { return(execPath); }
+
+ boolean run() {
+ String commandLine=execPath;
+ if(outputType==DXF) {
+ commandLine=commandLine+" -x "+outputFile+" "+execArgs;
+ }
+ if(!inputFile.equals("")) {
+ try {
+ commandLine+=" "+inputFile;
+ Runtime rtime = Runtime.getRuntime();
+ print("Command Line: "+commandLine+"\n");
+ Process child = rtime.exec(commandLine);
+ child.waitFor();
+ return(true);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return(false);
+ }
+ } else {
+ return(false);
+ }
+ }
+}
+
View
18 SuperSkein.pde
@@ -15,6 +15,8 @@ String DXFSliceFilePrefix = "dxf_slice";
// Set DXFExportMode=1 to switch render and enable dependent code.
int DXFExportMode = 1;
+// Set OpenSCADTestMode=1 to enable OpenSCAD test code.
+int OpenSCADTestMode=0;
//Non-GUI-Reachable but in ~config.txt
float PrintHeadSpeed = 2000.0;
@@ -455,7 +457,21 @@ class DXFWriteProc implements Runnable{
print("Z: " + CleanFloat(STLFile.bz1) + " - " + CleanFloat(STLFile.bz2) + " ");
if(STLFile.bz1<0)print("\n(Values below z=0 not exported.)");
- // open(OpenSCADFileName);
+ if(OpenSCADTestMode==1) {
+ OpenSCAD runOSCAD = new OpenSCAD();
+ runOSCAD.setInput(OpenSCADFileName);
+ runOSCAD.setOutput(DXF,OpenSCADFileName+".dxf");
+ print("Running OpenSCAD Process:\n");
+ print(" Exec Path: "+runOSCAD.getExecPath()+"\n");
+ print(" Exec Args: "+runOSCAD.getExecArgs()+"\n");
+ print(" Input File: "+runOSCAD.getInput()+"\n");
+ if(runOSCAD.run()) {
+ print("Run Finished!\n");
+ } else {
+ print("Run Error.\n");
+ }
+ // open(OpenSCADFileName);
+ }
MeshHeight=STLFile.bz2-STLFile.bz1;
STLLoadedFlag = true;

0 comments on commit 4f8973b

Please sign in to comment.