diff --git a/OSCADSharp/OSCADSharp.ConsoleTests/Program.cs b/OSCADSharp/OSCADSharp.ConsoleTests/Program.cs
index c1b74b7..18b6f36 100644
--- a/OSCADSharp/OSCADSharp.ConsoleTests/Program.cs
+++ b/OSCADSharp/OSCADSharp.ConsoleTests/Program.cs
@@ -26,7 +26,7 @@ namespace OSCADSharp.ConsoleTests
//var topCorner = new Sphere().Translate(obj.Bounds().TopRight);
//var botCorner = new Sphere().Translate(obj.Bounds().BottomLeft);
- (obj + axisHelper).ToFile("test.scad");
+ (obj + axisHelper).ToFile("test.scad").Open();
//Console.ReadKey();
}
diff --git a/OSCADSharp/OSCADSharp/OSCADObject.cs b/OSCADSharp/OSCADSharp/OSCADObject.cs
index 3e8b537..7e1d4a8 100644
--- a/OSCADSharp/OSCADSharp/OSCADObject.cs
+++ b/OSCADSharp/OSCADSharp/OSCADObject.cs
@@ -1,4 +1,5 @@
using OSCADSharp.Booleans;
+using OSCADSharp.Scripting;
using OSCADSharp.Spatial;
using OSCADSharp.Transforms;
using System;
@@ -320,7 +321,7 @@ namespace OSCADSharp
/// (This is just a shortcut for File.WriteAllLines)
///
/// Path for the file to write. Including filename and (optionally) file extension
- public void ToFile(string filePath)
+ public IFileInvoker ToFile(string filePath)
{
string path = filePath;
@@ -335,6 +336,8 @@ namespace OSCADSharp
Settings.Globals.ToString(),
this.ToString()
});
+
+ return new DefaultFileInvoker(filePath);
}
#endregion
diff --git a/OSCADSharp/OSCADSharp/OSCADSharp.csproj b/OSCADSharp/OSCADSharp/OSCADSharp.csproj
index 83d93cc..285d86a 100644
--- a/OSCADSharp/OSCADSharp/OSCADSharp.csproj
+++ b/OSCADSharp/OSCADSharp/OSCADSharp.csproj
@@ -42,6 +42,7 @@
+
diff --git a/OSCADSharp/OSCADSharp/Scripting/DefaultFileInvoker.cs b/OSCADSharp/OSCADSharp/Scripting/DefaultFileInvoker.cs
new file mode 100644
index 0000000..f67ad89
--- /dev/null
+++ b/OSCADSharp/OSCADSharp/Scripting/DefaultFileInvoker.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OSCADSharp.Scripting
+{
+ internal class DefaultFileInvoker : IFileInvoker
+ {
+ private string filePath;
+ public DefaultFileInvoker(string filePath)
+ {
+ this.filePath = filePath;
+ }
+
+ public void CreateModel(string outputFile)
+ {
+ Process.Start(Settings.OpenSCADPath, String.Format("-o {0} {1}", outputFile, this.filePath));
+ }
+
+ public void Open()
+ {
+ Process.Start(Settings.OpenSCADPath, String.Format("{0}", this.filePath));
+ }
+ }
+}
diff --git a/OSCADSharp/OSCADSharp/Scripting/IFileInvoker.cs b/OSCADSharp/OSCADSharp/Scripting/IFileInvoker.cs
index 52ee115..e220af8 100644
--- a/OSCADSharp/OSCADSharp/Scripting/IFileInvoker.cs
+++ b/OSCADSharp/OSCADSharp/Scripting/IFileInvoker.cs
@@ -7,15 +7,19 @@ using System.Threading.Tasks;
namespace OSCADSharp.Scripting
{
///
- /// Opens a file
+ /// Invokes OpenSCAD actions on output files
///
public interface IFileInvoker
{
///
- /// Opens the specified file
+ /// Launches OpenSCAD with the specified file open
///
- /// Path to the file to open
- /// Command-line arguments to pass in
- void Invoke(string path, string arguments = null);
+ void Open();
+
+ ///
+ /// Generates an STL from this file with the specified path/name
+ ///
+ ///
+ void CreateModel(string outputFile);
}
}
diff --git a/OSCADSharp/OSCADSharp/Settings.cs b/OSCADSharp/OSCADSharp/Settings.cs
index d6b183f..7a732c9 100644
--- a/OSCADSharp/OSCADSharp/Settings.cs
+++ b/OSCADSharp/OSCADSharp/Settings.cs
@@ -28,5 +28,11 @@ namespace OSCADSharp
/// Used to write scripts to file
///
public static IFileWriter FileWriter = new DefaultFileWriter();
+
+ ///
+ /// Path to the OpenSCAD executable for file invocation
+ /// (Default value is set the default install directory on Windows)
+ ///
+ public static string OpenSCADPath = @"C:\Program Files (x86)\OpenSCAD\openscad.exe";
}
}