-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ #1067 GlobalConfigurations dynamic GH comp (sqashed commit)
commit a74c768 Author: lorinczandrea <[email protected]> Date: Fri Aug 30 15:06:41 2024 +0200 :bug: error handling #1067 commit 09ed39e Author: lorinczandrea <[email protected]> Date: Thu Aug 29 20:42:26 2024 +0200 :construction: fix SetGlobalCfg #1067 still testing commit fa3d3fb Author: lorinczandrea <[email protected]> Date: Wed Aug 28 19:59:54 2024 +0200 :construction: dynamic GlobalConfig GH component #1067 waiting for test
- Loading branch information
1 parent
acb4136
commit c4be0e8
Showing
21 changed files
with
1,659 additions
and
163 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
124 changes: 124 additions & 0 deletions
124
FemDesign.Grasshopper/Calculate/Configurations/GlobalConfigs/GlobalConfigs.cs
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,124 @@ | ||
using Grasshopper.Kernel; | ||
using Grasshopper.Kernel.Parameters; | ||
using Grasshopper.Kernel.Types; | ||
using FemDesign.Grasshopper.Components.UIWidgets; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Drawing; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Rhino.Geometry; | ||
using FemDesign.Grasshopper; | ||
using System.Windows.Forms; | ||
using FemDesign.Grasshopper.Extension.ComponentExtension; | ||
using FemDesign.Loads; | ||
using Grasshopper.Kernel.Special; | ||
|
||
namespace FemDesign.Grasshopper | ||
{ | ||
public class GlobalConfigs : GH_SwitcherComponent | ||
{ | ||
private List<SubComponent> _subcomponents = new List<SubComponent>(); | ||
public override string UnitMenuName => "GlobalConfigs"; | ||
protected override string DefaultEvaluationUnit => _subcomponents[1].name(); | ||
public override Guid ComponentGuid => new Guid("{41175D83-48B2-4614-A074-DC8BE7F71CAC}"); | ||
public override GH_Exposure Exposure => GH_Exposure.quinary; | ||
|
||
protected override Bitmap Icon => FemDesign.Properties.Resources.Config; | ||
|
||
public GlobalConfigs() | ||
: base("GlobConfig", "GlobalConfigurations", | ||
"General calculation settings for a FEM-Design model.", | ||
CategoryName.Name(), SubCategoryName.Cat7a()) | ||
{ | ||
((GH_Component)this).Hidden = true; | ||
} | ||
|
||
protected override void RegisterInputParams(GH_InputParamManager pManager) | ||
{ | ||
} | ||
|
||
protected override void RegisterOutputParams(GH_OutputParamManager pManager) | ||
{ | ||
pManager.RegisterParam(new Param_GenericObject(), "GlobConfig", "GlobalConfiguration", "Global configurations."); | ||
} | ||
|
||
protected override void RegisterEvaluationUnits(EvaluationUnitManager mngr) | ||
{ | ||
//_subcomponents.Add(new SoilCalculationSettings()); | ||
_subcomponents.Add(new MeshGeneralSettings()); | ||
_subcomponents.Add(new MeshElementSettings()); | ||
_subcomponents.Add(new MeshFunctionSettings()); | ||
_subcomponents.Add(new MeshPrepareSettings()); | ||
_subcomponents.Add(new PeakSmMethodSettings()); | ||
_subcomponents.Add(new PeakSmAutoSettings()); | ||
|
||
foreach (SubComponent item in _subcomponents) | ||
{ | ||
item.registerEvaluationUnits(mngr); | ||
} | ||
} | ||
|
||
protected override void OnComponentLoaded() | ||
{ | ||
base.OnComponentLoaded(); | ||
foreach (SubComponent item in _subcomponents) | ||
{ | ||
item.OnComponentLoaded(); | ||
} | ||
} | ||
|
||
protected override void SolveInstance(IGH_DataAccess DA, EvaluationUnit unit) | ||
{ | ||
if (unit == null) | ||
{ | ||
return; | ||
} | ||
foreach (SubComponent item in _subcomponents) | ||
{ | ||
if (unit.Name.Equals(item.name())) | ||
{ | ||
item.SolveInstance(DA, out var msg, out var level); | ||
if (msg != "") | ||
{ | ||
((GH_ActiveObject)this).AddRuntimeMessage(level, msg); | ||
} | ||
return; | ||
} | ||
} | ||
throw new Exception("Invalid sub-component"); | ||
} | ||
// Part of the code that allows to extend the menu with additional items | ||
// Right click on the component to see the options | ||
public override void AppendAdditionalMenuItems(ToolStripDropDown menu) | ||
{ | ||
base.AppendAdditionalMenuItems(menu); | ||
if (evalUnits.Units.Count > 0) | ||
{ | ||
Menu_AppendSeparator(menu); | ||
ToolStripMenuItem toolStripMenuItem = Menu_AppendItem(menu, "GlobConfigs"); | ||
foreach (EvaluationUnit unit in evalUnits.Units) | ||
{ | ||
Menu_AppendItem(toolStripMenuItem.DropDown, unit.Name, Menu_ActivateUnit, null, true, unit.Active).Tag = unit; | ||
} | ||
Menu_AppendSeparator(menu); | ||
} | ||
} | ||
private void Menu_ActivateUnit(object sender, EventArgs e) | ||
{ | ||
try | ||
{ | ||
EvaluationUnit evaluationUnit = (EvaluationUnit)((ToolStripMenuItem)sender).Tag; | ||
if (evaluationUnit != null) | ||
{ | ||
SwitchUnit(evaluationUnit); | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
throw ex; | ||
} | ||
} | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
FemDesign.Grasshopper/Calculate/Configurations/GlobalConfigs/MeshElementSettings.cs
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,80 @@ | ||
using Grasshopper.Kernel; | ||
using Grasshopper.Kernel.Parameters; | ||
using Grasshopper.Kernel.Types; | ||
using FemDesign.Grasshopper.Components.UIWidgets; | ||
|
||
|
||
namespace FemDesign.Grasshopper | ||
{ | ||
public class MeshElementSettings : SubComponent | ||
{ | ||
public override string name() => "MeshElementSettings"; | ||
public override string display_name() => "MeshElementSettings"; | ||
|
||
public override void registerEvaluationUnits(EvaluationUnitManager mngr) | ||
{ | ||
EvaluationUnit evaluationUnit = new EvaluationUnit(name(), display_name(), "Finite element mesh elements settings. For more details, see the FEM-Design GUI > Settings > Calculation > Mesh."); | ||
mngr.RegisterUnit(evaluationUnit); | ||
|
||
evaluationUnit.RegisterInputParam(new Param_Number(), "Scale", "Scale", "Scale.", GH_ParamAccess.item); | ||
evaluationUnit.Inputs[evaluationUnit.Inputs.Count - 1].Parameter.Optional = true; | ||
|
||
evaluationUnit.RegisterInputParam(new Param_Boolean(), "Correct", "Correct", "Correct according to the minimum division numbers.\nDefault is True.", GH_ParamAccess.item); | ||
evaluationUnit.Inputs[evaluationUnit.Inputs.Count - 1].Parameter.Optional = true; | ||
|
||
evaluationUnit.RegisterInputParam(new Param_Boolean(), "RegionByRegion", "RegionByRegion", "Region by region.\nDefault is True. If false, the `Consider all regions together` option is set.", GH_ParamAccess.item); | ||
evaluationUnit.Inputs[evaluationUnit.Inputs.Count - 1].Parameter.Optional = true; | ||
|
||
evaluationUnit.RegisterInputParam(new Param_Integer(), "MinDivNumber", "MinDivNumber", "Lowest minimum division number.", GH_ParamAccess.item); | ||
evaluationUnit.Inputs[evaluationUnit.Inputs.Count - 1].Parameter.Optional = true; | ||
|
||
evaluationUnit.RegisterInputParam(new Param_Number(), "MaxCentralAngle", "MaxCentralAngle", "Maximal central angle for arcs.", GH_ParamAccess.item); | ||
evaluationUnit.Inputs[evaluationUnit.Inputs.Count - 1].Parameter.Optional = true; | ||
|
||
|
||
GH_ExtendableMenu gH_ExtendableMenu0 = new GH_ExtendableMenu(0, ""); | ||
gH_ExtendableMenu0.Name = "Calculated average element size"; | ||
gH_ExtendableMenu0.RegisterInputPlug(evaluationUnit.Inputs[0]); | ||
gH_ExtendableMenu0.RegisterInputPlug(evaluationUnit.Inputs[1]); | ||
gH_ExtendableMenu0.RegisterInputPlug(evaluationUnit.Inputs[2]); | ||
evaluationUnit.AddMenu(gH_ExtendableMenu0); | ||
|
||
|
||
GH_ExtendableMenu gH_ExtendableMenu1 = new GH_ExtendableMenu(1, ""); | ||
gH_ExtendableMenu1.Name = "Bar element"; | ||
gH_ExtendableMenu1.Expand(); | ||
gH_ExtendableMenu1.RegisterInputPlug(evaluationUnit.Inputs[3]); | ||
gH_ExtendableMenu1.RegisterInputPlug(evaluationUnit.Inputs[4]); | ||
evaluationUnit.AddMenu(gH_ExtendableMenu1); | ||
} | ||
|
||
public override void SolveInstance(IGH_DataAccess DA, out string msg, out GH_RuntimeMessageLevel level) | ||
{ | ||
msg = ""; | ||
level = GH_RuntimeMessageLevel.Warning; | ||
|
||
double scale = 6.0; | ||
DA.GetData(0, ref scale); | ||
|
||
bool correct = true; | ||
DA.GetData(1, ref correct); | ||
|
||
bool regByReg = true; | ||
DA.GetData(2, ref regByReg); | ||
|
||
int minDiv = 2; | ||
DA.GetData(3, ref minDiv); | ||
|
||
double angle = 10.00; | ||
DA.GetData(4, ref angle); | ||
|
||
var meshElem = new Calculate.MeshElements(regByReg, scale, correct, minDiv, angle); | ||
DA.SetData(0, meshElem); | ||
} | ||
|
||
protected void setModelProps() | ||
{ | ||
this.Parent_Component.ExpireSolution(true); | ||
} | ||
} | ||
} |
Oops, something went wrong.