Skip to content

Commit

Permalink
GSAGH-526: 'Open in GSA' in Save component in Rhino 8 does not open m…
Browse files Browse the repository at this point in the history
…odel (#728)

Co-authored-by: spsarras <[email protected]>
  • Loading branch information
DominikaLos and psarras authored Nov 27, 2024
1 parent ee54f89 commit 15077db
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
9 changes: 7 additions & 2 deletions GsaGH/Components/0_Model/SaveGsaModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ protected override void SolveInternal(IGH_DataAccess da) {
return;
}

var gsaModel = new GsaModel();
GsaModel gsaModel;
if (ghTyp.Value is GsaModelGoo modelGoo) {
gsaModel = modelGoo.Value;
Message = string.Empty;
Expand Down Expand Up @@ -175,8 +175,13 @@ internal void OpenGsaExe() {
GsaModel gsaModel = tempModel.Value;
Save(ref gsaModel, tempPath);
}
RunGsa();
}

Process.Start(_fileNameLastSaved);
internal Process RunGsa() {
string programFiles = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
string fullPath = Path.Combine(programFiles, @"Oasys\GSA 10.2\GSA.exe");
return Process.Start(fullPath, Path.GetFullPath(_fileNameLastSaved));
}
}
}
19 changes: 18 additions & 1 deletion GsaGHTests/3_Components/0_Model/SaveGsaModelTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.IO;
using System;
using System.Diagnostics;
using System.IO;

using GsaGH.Components;
using GsaGH.Parameters;
Expand Down Expand Up @@ -49,5 +51,20 @@ public void SaveGsaModelTest(string filename) {

Assert.True(File.Exists(expectedPath));
}

[Fact]
public void StartGsaShouldTargetGsa() {
SaveGsaModel comp = new SaveGsaModel();
ComponentTestHelper.SetInput(comp, GsaModelGooMother);
ComponentTestHelper.SetInput(comp, true, 1);
ComponentTestHelper.SetInput(comp, Path.Combine(Path.GetTempPath(), "dummyPath.gwb"), 2);
_ = (GsaModelGoo)ComponentTestHelper.GetOutput(comp);
var process = comp.RunGsa();
try {
Assert.Contains("GSA", process.ProcessName);
} finally {
process.Kill();
}
}
}
}

0 comments on commit 15077db

Please sign in to comment.