mirror of
https://github.com/eliasstepanik/OSCADSharpDotnet7.git
synced 2026-01-15 07:28:28 +00:00
Added getOpenSCADPath method to discover path to OpenSCAD executable amongst multiple options
This commit is contained in:
parent
7e7affcad4
commit
26f4d70876
@ -14,10 +14,11 @@ namespace OSCADSharp.ConsoleTests
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Variables.Global.Add("$fn", 100);
|
||||
Variables.Global.Add("sphereRadius", 15);
|
||||
|
||||
var obj = new Sphere();
|
||||
obj.Bind("Radius", Variables.Global["sphereRadius"]);
|
||||
|
||||
var obj = new Sphere(30);
|
||||
|
||||
var pos = obj.Position();
|
||||
var cyl1 = new Cylinder(1, 100, true).Translate(pos);
|
||||
var cyl2 = new Cylinder(1, 100, true).Rotate(0, 90, 0).Translate(pos);
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
using OSCADSharp.Scripting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -18,11 +19,28 @@ namespace OSCADSharp
|
||||
/// </summary>
|
||||
public static readonly string OSCADSharpHeader = String.Format("/*Code Generated using OSCADSharp on {0}. {1}{2}For more information, please visit https://github.com/Exolun/OSCADSharp */{3}",
|
||||
DateTime.Now.ToString(), Environment.NewLine, Environment.NewLine, Environment.NewLine);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Path to the OpenSCAD executable for file invocation
|
||||
/// (Default value is set the default install directory on Windows)
|
||||
/// </summary>
|
||||
public static string OpenSCADPath = @"C:\Program Files (x86)\OpenSCAD\openscad.exe";
|
||||
public static string OpenSCADPath = getOpenSCADPath();
|
||||
|
||||
private static string getOpenSCADPath()
|
||||
{
|
||||
string[] possibleFilePaths = new string[]
|
||||
{
|
||||
@"C:\Program Files (x86)\OpenSCAD\openscad.exe",
|
||||
@"C:\Program Files\OpenSCAD\openscad.exe"
|
||||
};
|
||||
|
||||
foreach (string path in possibleFilePaths)
|
||||
{
|
||||
if (File.Exists(path))
|
||||
return path;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user