Skip to main content

Get port information

Ports on a diagram's node shape can be accessed through the Ports property of the INode object obtained from IDiagram.

Access each port on a node

An example of enumerating the ports on the selected node shape of a diagram.

public void EnumeratePorts(ICommandContext c, ICommandParams p) 
{
IDiagram diagram = c.App.Workspace.CurrentEditor as IDiagram;
if (diagram == null) return;

//Get the selected nodes
var nodes = diagram.GetSelectedShapes().OfType<INode>();

//Process each node
foreach (INode node in nodes)
{
c.App.Output.WriteLine("sample", $"Node model : {node.Model.Name}");

//Process each port that the node has
foreach (IPort port in node.Ports)
{
c.App.Output.WriteLine("sample", $"Port model : {port.Model.Name}");
}
}
}