-
Notifications
You must be signed in to change notification settings - Fork 635
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
- Loading branch information
Showing
12 changed files
with
1,544 additions
and
622 deletions.
There are no files selected for viewing
528 changes: 528 additions & 0 deletions
528
doc/distrib/NodeHelpFiles/GeometryUIWpf.PanelSurfaceBoundaryConditionDropDown.dyn
Large diffs are not rendered by default.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
doc/distrib/NodeHelpFiles/GeometryUIWpf.PanelSurfaceBoundaryConditionDropDown.md
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,6 @@ | ||
## In Depth | ||
Dropdown node that allows easy selection of PanelSurface.BoundaryCondition values. | ||
___ | ||
## Example File | ||
|
||
![ByCrossSplitSquares](./GeometryUIWpf.PanelSurfaceBoundaryConditionDropDown_img.jpg) |
Binary file added
BIN
+879 KB
...strib/NodeHelpFiles/GeometryUIWpf.PanelSurfaceBoundaryConditionDropDown_img.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,15 @@ | ||
using Autodesk.DesignScript.Geometry; | ||
using Autodesk.DesignScript.Runtime; | ||
using System; | ||
|
||
namespace DSCore | ||
{ | ||
[IsVisibleInDynamoLibrary(false)] | ||
public class BoundaryConditionHelper | ||
{ | ||
public static PanelSurfaceBoundaryCondition BoundaryConditionFromString(string val) | ||
{ | ||
return Enum.Parse<PanelSurfaceBoundaryCondition>(val); | ||
} | ||
} | ||
} |
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
Large diffs are not rendered by default.
Oops, something went wrong.
78 changes: 78 additions & 0 deletions
78
src/Libraries/GeometryUI/PanelSurfaceBoundaryConditions.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,78 @@ | ||
using Autodesk.DesignScript.Geometry; | ||
using Autodesk.DesignScript.Runtime; | ||
using CoreNodeModels; | ||
using DSCore; | ||
using Dynamo.Graph.Nodes; | ||
using Dynamo.Utilities; | ||
using Newtonsoft.Json; | ||
using ProtoCore.AST.AssociativeAST; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace GeometryUI | ||
{ | ||
[IsVisibleInDynamoLibrary(true)] | ||
[NodeName("Select Boundary Condition")] | ||
[NodeCategory("Geometry.PanelSurface")] | ||
[NodeDescription("PanelSurfaceBoundaryConditionDropDownDesc", typeof(Properties.Resources))] | ||
[OutPortNames("PanelSurfaceBoundaryCondition")] | ||
[OutPortTypes(nameof(PanelSurfaceBoundaryCondition))] | ||
[OutPortDescriptions("PanelSurface BoundaryCondition enum value")] | ||
[IsDesignScriptCompatible] | ||
public class PanelSurfaceBoundaryConditionDropDown : DSDropDownBase | ||
{ | ||
public PanelSurfaceBoundaryConditionDropDown(): base("PanelSurfaceBoundaryCondition") { | ||
SelectedIndex = (int)PanelSurfaceBoundaryCondition.Keep; | ||
} | ||
|
||
[JsonConstructor] | ||
protected PanelSurfaceBoundaryConditionDropDown(IEnumerable<PortModel> inPorts, IEnumerable<PortModel> outPorts) : base(">", inPorts, outPorts) { } | ||
|
||
/// <summary> | ||
/// Overrides the default behavior to serialize internal enumeration id | ||
/// instead of the name of the enum constant. | ||
/// </summary> | ||
/// <param name="item">Selected DynamoDropDownItem</param> | ||
/// <returns>A string representing the internal enum id.</returns> | ||
protected override string GetSelectedStringFromItem(DynamoDropDownItem item) | ||
{ | ||
return item == null ? string.Empty : item.Item.ToString(); | ||
} | ||
|
||
protected override SelectionState PopulateItemsCore(string currentSelection) | ||
{ | ||
Items.Clear(); | ||
foreach (var constant in Enum.GetValues(typeof(PanelSurfaceBoundaryCondition))) | ||
{ | ||
Items.Add(new DynamoDropDownItem(constant.ToString(), constant)); | ||
} | ||
|
||
Items = Items.OrderBy(x => x.Name).ToObservableCollection(); | ||
return SelectionState.Restore; | ||
} | ||
|
||
/// <summary> | ||
/// Builds the output AST. | ||
/// </summary> | ||
public override IEnumerable<AssociativeNode> BuildOutputAst(List<AssociativeNode> inputAstNodes) | ||
{ | ||
if (SelectedIndex < 0 || SelectedIndex >= Items.Count) | ||
return new[] { AstFactory.BuildNullNode() }; | ||
|
||
var selection = | ||
AstFactory.BuildStringNode(Items[SelectedIndex].Name); | ||
|
||
var func = AstFactory.BuildFunctionCall( | ||
new Func<string, PanelSurfaceBoundaryCondition>(BoundaryConditionHelper.BoundaryConditionFromString), | ||
new List<AssociativeNode> { selection }); | ||
|
||
// Assign the selected name to an actual enumeration value | ||
var assign = AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), func); | ||
|
||
// Return the enumeration value | ||
return new List<AssociativeNode> { assign }; | ||
} | ||
} | ||
|
||
} |
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
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