diff --git a/src/PollinationSDK/Helper/Helper.cs b/src/PollinationSDK/Helper/Helper.cs
index 26c74156..0b3db068 100644
--- a/src/PollinationSDK/Helper/Helper.cs
+++ b/src/PollinationSDK/Helper/Helper.cs
@@ -485,12 +485,17 @@ internal static void CopyDirectory(string sDir, string dDir)
/// Execute *.sh file on Mac or *.bat on Windows
///
///
- public static void RunScriptFile(string scriptFile)
+ public static void RunScriptFile(string scriptFile, bool silentMode)
{
if (!Utilities.IsMac)
{
//Windows
- var p = System.Diagnostics.Process.Start(scriptFile);
+ var pInfo = new System.Diagnostics.ProcessStartInfo(scriptFile);
+ if (silentMode)
+ pInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
+
+ var p = System.Diagnostics.Process.Start(pInfo);
+
p.WaitForExit();
}
else //Mac
diff --git a/src/PollinationSDK/Wrapper/JobInfo.cs b/src/PollinationSDK/Wrapper/JobInfo.cs
index 824e6257..94129181 100644
--- a/src/PollinationSDK/Wrapper/JobInfo.cs
+++ b/src/PollinationSDK/Wrapper/JobInfo.cs
@@ -19,6 +19,7 @@ public class JobInfo
public string ProjectSlug { get; set; } // for cloud and local job, ladybug_tools/demoProject
public int LocalCPUNumber { get; set; } // for local job only
public string LocalRunFolder { get; set; } // for local job only
+ public bool LocalSilentMode { get; set; } // for local job only
public string Platform { get; set; } = "unknown"; // rhino, revit, grasshopper
public string LocalJobStatus { get; set; } = "unknown"; // RunStatusEnum for a local job
@@ -57,6 +58,15 @@ public void SetLocalJob(string projectOwner, string projectName, string runFolde
this.LocalCPUNumber = cpuNo;
}
+ public void SetLocalSilentMode(bool enableSilent)
+ {
+ if (this.IsLocalJob)
+ this.LocalSilentMode = enableSilent;
+ else
+ throw new ArgumentException("Silent mode only works with local job! Call SetLocalJob() to set local job settings first!");
+
+ }
+
public void SetJobAuthor(AccountPublic authorAccount)
{
this.JobAuthor = authorAccount;
@@ -243,8 +253,9 @@ private async Task RunJobOnLocalAsync()
var workDir = this.LocalRunOutputFolder;
var cpuNum = this.LocalCPUNumber;
+ var isSilentMode = this.LocalSilentMode;
var runner = new JobRunner(this);
- var runout = await Task.Run(() => runner.RunOnLocalMachine(workDir, cpuNum)).ConfigureAwait(false);
+ var runout = await Task.Run(() => runner.RunOnLocalMachine(workDir, cpuNum, isSilentMode)).ConfigureAwait(false);
// check local job status
var status = JobRunner.CheckLocalJobStatus(runout);
this.LocalJobStatus = status.ToString();
diff --git a/src/PollinationSDK/Wrapper/JobRunner.cs b/src/PollinationSDK/Wrapper/JobRunner.cs
index 909027ac..14aadb74 100644
--- a/src/PollinationSDK/Wrapper/JobRunner.cs
+++ b/src/PollinationSDK/Wrapper/JobRunner.cs
@@ -143,7 +143,7 @@ private async Task ScheduleCloudJobAsync(
}
- public string RunOnLocalMachine(string workFolder, int workerNum)
+ public string RunOnLocalMachine(string workFolder, int workerNum, bool silentMode)
{
if (string.IsNullOrEmpty(Utilities.PythonRoot) || !Directory.Exists(Utilities.PythonRoot))
throw new ArgumentException("Missing some setting for local simulations, please use Utilities.SetPaths before running any local simulations");
@@ -189,7 +189,7 @@ public string RunOnLocalMachine(string workFolder, int workerNum)
File.WriteAllText(scriptFile, script);
// dealing with both windows and mac
- Helper.RunScriptFile(scriptFile);
+ Helper.RunScriptFile(scriptFile, silentMode);
}
catch (Exception ex)
{