-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…-component gsagh-121 gwa command component
- Loading branch information
Showing
7 changed files
with
110 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -354,3 +354,4 @@ dist/* | |
/IntegrationTests/obj | ||
|
||
/GhSA/bin/x64/Release | ||
/UnitTestGsaGH/bin/x64/Debug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Drawing; | ||
using System.IO; | ||
using Grasshopper.Kernel; | ||
using GsaAPI; | ||
using GsaGH.Parameters; | ||
|
||
|
||
namespace GsaGH.Components | ||
{ | ||
/// <summary> | ||
/// Component to create a GSA model from GWA string | ||
/// </summary> | ||
public class GwaModel : GH_OasysComponent | ||
{ | ||
#region Name and Ribbon Layout | ||
public override Guid ComponentGuid => new Guid("6f701c53-1531-45ef-9842-9356da59b590"); | ||
public override GH_Exposure Exposure => GH_Exposure.tertiary | GH_Exposure.obscure; | ||
protected override System.Drawing.Bitmap Icon => GsaGH.Properties.Resources.GwaModel; | ||
public GwaModel() | ||
: base("Create GWA Model", "GWA", "Create a model from a GWA string.", | ||
Ribbon.CategoryName.Name(), | ||
Ribbon.SubCategoryName.Cat0()) | ||
{ this.Hidden = true; } // sets the initial state of the component to hidden | ||
#endregion | ||
|
||
#region Input and output | ||
protected override void RegisterInputParams(GH_InputParamManager pManager) | ||
{ | ||
pManager.AddTextParameter("GWA string", "GWA", "GWA string from GSA. Right-click on any data, and select copy all. Paste into notepad to check the data. \r\nThis input takes a a list of text strings that will automatically be joined. Construct a tree structure if you want to create multiple GSA files. \r\nThe syntax of the command is based on GWA syntax and the units follow the GWA unit syntax; –\r\nrefer to the “GSA Keywords” document for details", GH_ParamAccess.list); | ||
} | ||
|
||
protected override void RegisterOutputParams(GH_OutputParamManager pManager) | ||
{ | ||
pManager.AddParameter(new GsaModelParameter()); | ||
} | ||
#endregion | ||
|
||
protected override void SolveInstance(IGH_DataAccess DA) | ||
{ | ||
Interop.Gsa_10_1.ComAuto m = new Interop.Gsa_10_1.ComAuto(); | ||
m.NewFile(); | ||
string gwa = ""; | ||
List<string> strings = new List<string>(); | ||
if (DA.GetDataList(0, strings)) | ||
foreach (string s in strings) | ||
gwa += s + "\n"; | ||
|
||
m.GwaCommand(gwa); | ||
string temp = Path.GetTempPath() + Guid.NewGuid().ToString() + ".gwb"; | ||
m.SaveAs(temp); | ||
GsaModel gsaGH = new GsaModel(); | ||
gsaGH.Model.Open(temp); | ||
DA.SetData(0, gsaGH); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters