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 1 commit
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
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
53 changes: 53 additions & 0 deletions src/Libraries/GeometryUIWpf/PanelSurfaceBoundaryConditions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using Autodesk.DesignScript.Geometry;
using Autodesk.DesignScript.Runtime;
using CoreNodeModels;
using DSCore;
using Dynamo.Graph.Nodes;
using ProtoCore.AST.AssociativeAST;
using System;
using System.Collections.Generic;

namespace GeometryUIWpf
{
[IsVisibleInDynamoLibrary(true)]
[NodeName("PanelSurfaceBoundaryConditions")]
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we just make this singular like the enum itself - PanelSurfaceBoundaryCondition?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PanelSurfaceBoundaryCondition will collide with the ENum coming from ProtoGeom (at least in the library view)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@aparajit-pratap is the layout spec good enough for now ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you move the other PanelSurfaceBoundaryCondition node under this new BoundaryConditioncategory as well? I think more than one node can have the same name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

or maybe there's a special setting to allow same name nodes under the same parent ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or I can change the name of the new node (again)

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe only the same named nodes are allowed if and only if they have different inputs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Amoursol what do you think about the layout above ? 2 entries with the same name "PanelSurfaceBoundaryCOndition"
ONe is a dropdown node, the other is category (I think) for individual boundaryCOndition nodes

Copy link
Contributor

@Amoursol Amoursol Jun 3, 2024

Choose a reason for hiding this comment

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

@pinzart90 As it's still experimental, I don't think layoutspec changes matter too much. So we can do any of those changes and evaluate later if need be.

On the name front, could we please name it "Select Boundary Condition"? This is similar to some Revit paradigms. Do we also need to mark it an Action, not a Query?

image

Probably not plural - unlike image. Sorry on that miss!

[NodeCategory("Geometry.PanelSurface")]
aparajit-pratap marked this conversation as resolved.
Show resolved Hide resolved
[IsDesignScriptCompatible]
public class PanelSurfaceBoundaryConditionDropDown : EnumBase<PanelSurfaceBoundaryCondition>
aparajit-pratap marked this conversation as resolved.
Show resolved Hide resolved
{
/// <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();
}

/// <summary>
/// Builds the output AST.
/// </summary>
public override IEnumerable<AssociativeNode> BuildOutputAst(List<AssociativeNode> inputAstNodes)
{
//Some of the legacy categories which were not working before will now be out of index.
if (SelectedIndex < 0 || SelectedIndex >= Items.Count)
return new[] { AstFactory.BuildNullNode() };

var unitID =
AstFactory.BuildStringNode(Items[SelectedIndex].Name);

var node = AstFactory.BuildFunctionCall(
new Func<string, PanelSurfaceBoundaryCondition>(BoundaryConditionHelper.BoundaryConditionFromString),
new List<AssociativeNode> { unitID });

// Assign the selected name to an actual enumeration value
var assign = AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), node);

// Return the enumeration value
return new List<AssociativeNode> { assign };
}
}

}
Loading