Skip to content

Commit

Permalink
✨ keep open on Application Run
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco-Pellegrino committed Mar 6, 2024
1 parent 7e318e7 commit ad456f6
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions FemDesign.Grasshopper/Calculate/ApplicationRun.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ public class ApplicationRun : FEM_Design_API_Component
public ApplicationRun() : base("Application.Run", "RunApplication", "Run application for a model.", CategoryName.Name(), SubCategoryName.Cat7a())
{
_minimised = false;
_keepOpen = false;
}

public bool _minimised { get; set; }
public bool _keepOpen { get; set; }

protected override void RegisterInputParams(GH_InputParamManager pManager)
{
Expand Down Expand Up @@ -57,7 +59,7 @@ protected override void RegisterInputParams(GH_InputParamManager pManager)

pManager.AddTextParameter("DocxTemplatePath", "DocxTemplatePath", "File path to documentation template file (.dsc). The documentation will be saved in the `FEM-Design API` folder. Optional parameter.", GH_ParamAccess.item);
pManager[pManager.ParamCount - 1].Optional = true;
pManager.AddTextParameter("SaveFilePath", "SaveFilePath", "File path where to save the model as .strux.\nIf not specified, the file will be saved in the `FEM-Design API` folder adjacent to your .gh script.", GH_ParamAccess.item);
pManager.AddTextParameter("SaveFilePath", "SaveFilePath", "File path where to save the model as .struxml.\nIf not specified, the file will be saved in the `FEM-Design API` folder adjacent to your .gh script.", GH_ParamAccess.item);
pManager[pManager.ParamCount - 1].Optional = true;
pManager.AddBooleanParameter("RunNode", "RunNode", "If true node will execute. If false node will not execute.", GH_ParamAccess.item, true);
pManager[pManager.ParamCount - 1].Optional = true;
Expand Down Expand Up @@ -85,7 +87,8 @@ public dynamic _getResults(FemDesignConnection connection, Type resultType, Resu
protected override void AppendAdditionalComponentMenuItems(System.Windows.Forms.ToolStripDropDown menu)
{
// Append the item to the menu, making sure it's always enabled and checked if Absolute is True.
ToolStripMenuItem item = Menu_AppendItem(menu, "Minimise FEM-Design", Menu_AbsoluteClicked, null, true, _minimised);
ToolStripMenuItem minimisedItem = Menu_AppendItem(menu, "Minimise FEM-Design", Menu_AbsoluteClicked, null, true, _minimised);
ToolStripMenuItem keepOpenItem = Menu_AppendItem(menu, "Keep open", keepOpenClick, null, true, _keepOpen);
}

private void Menu_AbsoluteClicked(object sender, EventArgs e)
Expand All @@ -94,6 +97,12 @@ private void Menu_AbsoluteClicked(object sender, EventArgs e)
ExpireSolution(true);
}

private void keepOpenClick(object sender, EventArgs e)
{
_keepOpen = !_keepOpen;
ExpireSolution(true);
}


protected override void SolveInstance(IGH_DataAccess DA)
{
Expand Down Expand Up @@ -184,7 +193,7 @@ protected override void SolveInstance(IGH_DataAccess DA)
// Create Task
var t = Task.Run((Action)(() =>
{
var connection = new FemDesign.FemDesignConnection(minimized: _minimised);
var connection = new FemDesign.FemDesignConnection(minimized: _minimised, keepOpen: _keepOpen);

connection.Open(_model.Value);

Expand Down Expand Up @@ -284,4 +293,4 @@ public override Guid ComponentGuid
public override GH_Exposure Exposure => GH_Exposure.primary;

}
}
}

0 comments on commit ad456f6

Please sign in to comment.