Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DYN-6840: add new boundary condition node #15270

Merged
merged 17 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

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)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions src/Libraries/CoreNodes/ProtoGeometryHelper.cs
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);
}
}
}
aparajit-pratap marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions src/Libraries/GeometryUI/GeometryUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<Name>DynamoServices</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\CoreNodeModels\CoreNodeModels.csproj" />
<ProjectReference Include="..\DynamoConversions\DynamoConversions.csproj">
<Project>{c5adc05b-34e8-47bf-8e78-9c7bf96418c2}</Project>
<Name>DynamoConversions</Name>
Expand Down
1,482 changes: 875 additions & 607 deletions src/Libraries/GeometryUI/GeometryUIImages.resx

Large diffs are not rendered by default.

78 changes: 78 additions & 0 deletions src/Libraries/GeometryUI/PanelSurfaceBoundaryConditions.cs
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("PanelSurfaceBoundaryCondition")]
[NodeCategory("Geometry.PanelSurface")]
[NodeDescription("PanelSurfaceBoundaryConditionDropDownDesc", typeof(Properties.Resources))]
[OutPortNames("PanelSurfaceBoundaryCondition")]
[OutPortTypes(nameof(PanelSurfaceBoundaryCondition))]
[OutPortDescriptions("PanelSurface BoundaryCondition enum value")]
[IsDesignScriptCompatible]
public class PanelSurfaceBoundaryConditionDropDown : DSDropDownBase
Copy link
Member

@mjkkirschner mjkkirschner May 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also an EnumBase class inside Dynamo, but it generates the string values not the actual enum types.

public abstract class EnumBase<T> : DSDropDownBase

I guess they could all be made into a more generic class. I would consolidate them in another task

{
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();
aparajit-pratap marked this conversation as resolved.
Show resolved Hide resolved
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 };
}
}

}
9 changes: 9 additions & 0 deletions src/Libraries/GeometryUI/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/Libraries/GeometryUI/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@
<data name="ImportToSATUnitsDesc" xml:space="preserve">
<value>Imports geometry from SAT filepath. Set the dynamoUnit input to match how you are interpreting the other numbers in your Dynamo file.</value>
</data>
<data name="PanelSurfaceBoundaryConditionDropDownDesc" xml:space="preserve">
<value>A drop down node that allow easy access to PanelSurface BoundaryCondition possible values</value>
</data>
<data name="SABSATGeoDesc" xml:space="preserve">
<value>Loaded geometry</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions src/Libraries/GeometryUI/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@
<data name="ImportToSATUnitsDesc" xml:space="preserve">
<value>Imports geometry from SAT filepath. Set the dynamoUnit input to match how you are interpreting the other numbers in your Dynamo file.</value>
</data>
<data name="PanelSurfaceBoundaryConditionDropDownDesc" xml:space="preserve">
<value>A drop down node that allow easy access to PanelSurface BoundaryCondition possible values</value>
</data>
<data name="SABSATGeoDesc" xml:space="preserve">
<value>Loaded geometry</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1477,20 +1477,31 @@
"childElements": []
},
{
"text": "PanelSurface",
"iconUrl": "",
"elementType": "group",
"include": [
{
"path": "ProtoGeometry.Autodesk.DesignScript.Geometry.PanelSurface",
"inclusive": false
},
{
"path": "ProtoGeometry.Autodesk.DesignScript.Geometry.PanelSurfaceBoundaryCondition",
"inclusive": true
}
],
"childElements": []
"text": "PanelSurface",
"iconUrl": "",
"elementType": "group",
"include": [
{
"path": "ProtoGeometry.Autodesk.DesignScript.Geometry.PanelSurface",
"inclusive": false
},
{
"path": "Geometry.PanelSurface.PanelSurfaceBoundaryCondition"
}
],
"childElements": [
{
"text": "BoundaryCondition",
"iconUrl": "",
"elementType": "group",
"include": [
{
"path": "ProtoGeometry.Autodesk.DesignScript.Geometry.PanelSurfaceBoundaryCondition",
"inclusive": true
}
]
}
]
},
{
"text": "Modifiers",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public void ProducesCorrectOutputFromCoreDirectory_preloadedbinaries()
FromDirectoryCommand.HandleDocumentationFromDirectory(opts);

var generatedFileNames = tempDirectory.GetFiles().Select(x => x.Name);
Assert.AreEqual(709, generatedFileNames.Count());
Assert.AreEqual(707, generatedFileNames.Count());
}

[Test]
Expand Down
Loading