diff --git a/.gitignore b/.gitignore index 22e1a237f..50c980cb3 100644 --- a/.gitignore +++ b/.gitignore @@ -354,3 +354,4 @@ dist/* /IntegrationTests/obj /GhSA/bin/x64/Release +/UnitTestGsaGH/bin/x64/Debug diff --git a/GsaGH/Components/0_Model/GwaModel.cs b/GsaGH/Components/0_Model/GwaModel.cs new file mode 100644 index 000000000..ff8bf1c91 --- /dev/null +++ b/GsaGH/Components/0_Model/GwaModel.cs @@ -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 +{ + /// + /// Component to create a GSA model from GWA string + /// + 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 strings = new List(); + 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); + } + } +} diff --git a/GsaGH/GsaGH.csproj b/GsaGH/GsaGH.csproj index b1269b765..44c05819b 100644 --- a/GsaGH/GsaGH.csproj +++ b/GsaGH/GsaGH.csproj @@ -58,6 +58,10 @@ ..\..\..\..\..\..\Program Files\Oasys\GSA 10.1\GsaAPI.dll False + + ..\..\..\..\..\..\Program Files\Oasys\GSA 10.1\Interop.Gsa_10_1.dll + True + ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll @@ -99,6 +103,7 @@ + @@ -641,6 +646,9 @@ + + +