本文整理汇总了C#中Dynamo.Models.NodeMigrationData.FindConnectors方法的典型用法代码示例。如果您正苦于以下问题:C# NodeMigrationData.FindConnectors方法的具体用法?C# NodeMigrationData.FindConnectors怎么用?C# NodeMigrationData.FindConnectors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dynamo.Models.NodeMigrationData
的用法示例。
在下文中一共展示了NodeMigrationData.FindConnectors方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Migrate_0630_to_0700
public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
{
var migrationData = new NodeMigrationData(data.Document);
// Create DSFunction node
XmlElement oldNode = data.MigratedNodes.ElementAt(0);
var newNode = MigrationManager.CreateFunctionNodeFrom(oldNode);
MigrationManager.SetFunctionSignature(newNode, "ProtoGeometry.dll",
"Geometry.Intersect", "[email protected]");
migrationData.AppendNode(newNode);
string newNodeId = MigrationManager.GetGuidFromXmlElement(newNode);
var oldInPort0 = new PortId(newNodeId, 0, PortType.INPUT);
var connector0 = data.FindFirstConnector(oldInPort0);
var oldInPort1 = new PortId(newNodeId, 1, PortType.INPUT);
var connector1 = data.FindFirstConnector(oldInPort1);
data.ReconnectToPort(connector0, oldInPort0);
data.ReconnectToPort(connector1, oldInPort1);
// reconnect output port at 1 to 0
var oldXYZOut = new PortId(newNodeId, 1, PortType.OUTPUT);
var newXyzOut = new PortId(newNodeId, 0, PortType.OUTPUT);
var xyzConnects = data.FindConnectors(oldXYZOut);
xyzConnects.ToList().ForEach(x => data.ReconnectToPort(x, newXyzOut));
// get u parm
if (connector0 != null)
{
var crvInputNodeId = connector0.Attributes["start"].Value;
var crvInputIndex = int.Parse(connector0.Attributes["start_index"].Value);
// make parm at point node
var parmAtPt = MigrationManager.CreateFunctionNode(
data.Document, "ProtoGeometry.dll",
"Curve.ParameterAtPoint",
"[email protected]");
migrationData.AppendNode(parmAtPt);
var parmAtPtId = MigrationManager.GetGuidFromXmlElement(parmAtPt);
// connect output of project to parm at pt
data.CreateConnectorFromId(crvInputNodeId, crvInputIndex, parmAtPtId, 0);
data.CreateConnector(newNode, 0, parmAtPt, 1);
// reconnect remaining output ports to new nodes
var newTOut = new PortId(parmAtPtId, 0, PortType.OUTPUT);
var oldTOut = new PortId(newNodeId, 2, PortType.OUTPUT);
var oldTConnectors = data.FindConnectors(oldTOut);
oldTConnectors.ToList().ForEach(x => data.ReconnectToPort(x, newTOut));
}
// get v parm
if (connector1 != null)
{
var crvInputNodeId = connector1.Attributes["start"].Value;
var crvInputIndex = int.Parse(connector1.Attributes["start_index"].Value);
// make parm at point node
var parmAtPt = MigrationManager.CreateFunctionNode(
data.Document, "ProtoGeometry.dll",
"Curve.ParameterAtPoint",
"[email protected]");
migrationData.AppendNode(parmAtPt);
var parmAtPtId = MigrationManager.GetGuidFromXmlElement(parmAtPt);
// connect output of project to parm at pt
data.CreateConnectorFromId(crvInputNodeId, crvInputIndex, parmAtPtId, 0);
data.CreateConnector(newNode, 0, parmAtPt, 1);
// reconnect remaining output ports to new nodes
var newTOut = new PortId(parmAtPtId, 0, PortType.OUTPUT);
var oldTOut = new PortId(newNodeId, 3, PortType.OUTPUT);
var oldTConnectors = data.FindConnectors(oldTOut);
oldTConnectors.ToList().ForEach(x => data.ReconnectToPort(x, newTOut));
}
return migrationData;
}
示例2: Migrate_0630_to_0700
public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
{
NodeMigrationData migrationData = new NodeMigrationData(data.Document);
XmlElement oldNode = data.MigratedNodes.ElementAt(0);
string oldNodeId = MigrationManager.GetGuidFromXmlElement(oldNode);
XmlElement newNode = MigrationManager.CloneAndChangeType(oldNode, "DSCore.Filter");
newNode.SetAttribute("nickname", "Filter");
string newNodeId = MigrationManager.GetGuidFromXmlElement(newNode);
PortId oldOutputPort = new PortId(oldNodeId, 0, PortType.OUTPUT);
PortId newOutputPort = new PortId(newNodeId, 1, PortType.OUTPUT);
if (data.FindConnectors(oldOutputPort) != null)
foreach (XmlElement connector in data.FindConnectors(oldOutputPort))
data.ReconnectToPort(connector, newOutputPort);
PortId oldInPort0 = new PortId(oldNodeId, 0, PortType.INPUT);
XmlElement connector0 = data.FindFirstConnector(oldInPort0);
PortId oldInPort1 = new PortId(oldNodeId, 1, PortType.INPUT);
XmlElement connector1 = data.FindFirstConnector(oldInPort1);
PortId newInPort0 = new PortId(newNodeId, 0, PortType.INPUT);
PortId newInPort1 = new PortId(newNodeId, 1, PortType.INPUT);
data.ReconnectToPort(connector0, newInPort1);
data.ReconnectToPort(connector1, newInPort0);
migrationData.AppendNode(newNode);
return migrationData;
}
示例3: Migrate_0630_to_0700
public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
{
var migratedData = new NodeMigrationData(data.Document);
var oldNode = data.MigratedNodes.ElementAt(0);
string oldNodeId = MigrationManager.GetGuidFromXmlElement(oldNode);
var codeBlockNode = MigrationManager.CreateCodeBlockNodeFrom(oldNode);
codeBlockNode.SetAttribute("CodeText",
"p=Plane.ByOriginNormal(origin,axis.AsVector());\n"+
"cs=CoordinateSystem.ByPlane(p);\n"+
"Cylinder.ByRadiusHeight(cs,r,h);");
migratedData.AppendNode(codeBlockNode);
//create and reconnect the connecters
var oldInPort0 = new PortId(oldNodeId, 0, PortType.INPUT);
XmlElement connector0 = data.FindFirstConnector(oldInPort0);
var oldInPort1 = new PortId(oldNodeId, 1, PortType.INPUT);
XmlElement connector1 = data.FindFirstConnector(oldInPort1);
var oldInPort2 = new PortId(oldNodeId, 2, PortType.INPUT);
XmlElement connector2 = data.FindFirstConnector(oldInPort2);
var oldInPort3 = new PortId(oldNodeId, 3, PortType.INPUT);
XmlElement connector3 = data.FindFirstConnector(oldInPort3);
var oldOutPort0 = new PortId(oldNodeId, 0, PortType.OUTPUT);
var oldOutConnectors = data.FindConnectors(oldOutPort0);
var newInPort0 = new PortId(oldNodeId, 0, PortType.INPUT);
var newInPort1 = new PortId(oldNodeId, 1, PortType.INPUT);
var newInPort2 = new PortId(oldNodeId, 2, PortType.INPUT);
var newInPort3 = new PortId(oldNodeId, 3, PortType.INPUT);
var newOutPort2 = new PortId(oldNodeId, 2, PortType.OUTPUT);
data.ReconnectToPort(connector0, newInPort1);
data.ReconnectToPort(connector1, newInPort0);
data.ReconnectToPort(connector2, newInPort2);
data.ReconnectToPort(connector3, newInPort3);
if (oldOutConnectors.Any())
{
foreach (var connector in oldOutConnectors)
{
//connect anything that previously was connected to output port 0
//to output port 2
data.ReconnectToPort(connector, newOutPort2);
}
}
return migratedData;
}
示例4: Migrate_0630_to_0700
public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
{
var migrationData = new NodeMigrationData(data.Document);
#region Create DSFunction node
XmlElement oldNode = data.MigratedNodes.ElementAt(0);
var newNode = MigrationManager.CreateFunctionNodeFrom(oldNode);
MigrationManager.SetFunctionSignature(newNode, "ProtoGeometry.dll",
"Geometry.Intersect", "[email protected]");
migrationData.AppendNode(newNode);
string newNodeId = MigrationManager.GetGuidFromXmlElement(newNode);
var oldInPort0 = new PortId(newNodeId, 0, PortType.Input);
var faceInConnector = data.FindFirstConnector(oldInPort0);
var oldInPort1 = new PortId(newNodeId, 1, PortType.Input);
var crvInConnector = data.FindFirstConnector(oldInPort1);
// probably unnecessary
data.ReconnectToPort(faceInConnector, oldInPort0);
data.ReconnectToPort(crvInConnector, oldInPort1);
#endregion
// in ports of curve-face intersection
// 1) crv -> stays the same
// 2) face -> stays the same
// out ports of curve-face intersection
// 1) result -> this will be killed off by the migration
// 2) xyz -> this is out port 1 of oldNode
// 3) uv -> use Surface.ParameterAtPoint
// 4) t -> use Curve.ParameterAtPoint
// 5) edge -> killed
// 6) edge t -> killed
// reconnect output port at 1 to 0
var oldXYZOut = new PortId(newNodeId, 1, PortType.Output);
var newXyzOut = new PortId(newNodeId, 0, PortType.Output);
var xyzConnects = data.FindConnectors(oldXYZOut);
if (xyzConnects != null)
{
xyzConnects.ToList().ForEach(x => data.ReconnectToPort(x, newXyzOut));
}
// get uv parm
if (faceInConnector != null)
{
var faceInputNodeId = faceInConnector.Attributes["start"].Value;
var faceInputIndex = int.Parse(faceInConnector.Attributes["start_index"].Value);
// get the parameter as a vector
var parmAtPt = MigrationManager.CreateFunctionNode(
data.Document, oldNode, 0, "ProtoGeometry.dll",
"Surface.UVParameterAtPoint",
"[email protected]");
migrationData.AppendNode(parmAtPt);
var parmAtPtId = MigrationManager.GetGuidFromXmlElement(parmAtPt);
// connect output of project to parm at pt
data.CreateConnectorFromId(faceInputNodeId, faceInputIndex, parmAtPtId, 0);
data.CreateConnector(newNode, 0, parmAtPt, 1);
// reconnect remaining output ports to new nodes
var newUVOut = new PortId(parmAtPtId, 0, PortType.Output);
var oldUVOut = new PortId(newNodeId, 2, PortType.Output);
var oldUVConnectors = data.FindConnectors(oldUVOut);
if (oldUVConnectors != null)
oldUVConnectors.ToList().ForEach(x => data.ReconnectToPort(x, newUVOut));
}
// get v parm
if (crvInConnector != null)
{
var crvInputNodeId = crvInConnector.Attributes["start"].Value;
var crvInputIndex = int.Parse(crvInConnector.Attributes["start_index"].Value);
// make parm at point node
var parmAtPt = MigrationManager.CreateFunctionNode(
data.Document, oldNode, 0, "ProtoGeometry.dll",
"Curve.ParameterAtPoint",
"[email protected]");
migrationData.AppendNode(parmAtPt);
var parmAtPtId = MigrationManager.GetGuidFromXmlElement(parmAtPt);
// connect output of project to parm at pt
data.CreateConnectorFromId(crvInputNodeId, crvInputIndex, parmAtPtId, 0);
data.CreateConnector(newNode, 0, parmAtPt, 1);
// reconnect remaining output ports to new nodes
var newTOut = new PortId(parmAtPtId, 0, PortType.Output);
var oldTOut = new PortId(newNodeId, 3, PortType.Output);
var oldTConnectors = data.FindConnectors(oldTOut);
if (oldTConnectors != null)
//.........这里部分代码省略.........
示例5: Migrate_0630_to_0700
public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
{
NodeMigrationData migrationData = new NodeMigrationData(data.Document);
#region Create new DSFunction node - [email protected]
XmlElement oldNode = data.MigratedNodes.ElementAt(0);
var newNode = MigrationManager.CreateFunctionNodeFrom(oldNode);
MigrationManager.SetFunctionSignature(newNode, "ProtoGeometry.dll",
"Geometry.GetClosestPoint", "[email protected]");
migrationData.AppendNode(newNode);
string newNodeId = MigrationManager.GetGuidFromXmlElement(newNode);
var oldInPort0 = new PortId(newNodeId, 0, PortType.INPUT);
var ptInConnector = data.FindFirstConnector(oldInPort0);
var oldInPort1 = new PortId(newNodeId, 1, PortType.INPUT);
var faceInConnector = data.FindFirstConnector(oldInPort1);
data.ReconnectToPort(ptInConnector, oldInPort1);
data.ReconnectToPort(faceInConnector, oldInPort0);
#endregion
#region Reconnect the old UV out port
// if necessary, get the face UV
var oldUVOut = new PortId(newNodeId, 1, PortType.OUTPUT);
var oldUVConnectors = data.FindConnectors(oldUVOut);
if (oldUVConnectors != null && oldUVConnectors.Any())
{
// make parm at point node
var parmAtPt = MigrationManager.CreateFunctionNode(
data.Document, oldNode, 0, "ProtoGeometry.dll",
"Surface.UVParameterAtPoint",
"[email protected]");
migrationData.AppendNode(parmAtPt);
var parmAtPtId = MigrationManager.GetGuidFromXmlElement(parmAtPt);
var crvInputNodeId = faceInConnector.Attributes["start"].Value;
var crvInputIndex = int.Parse(faceInConnector.Attributes["start_index"].Value);
// connect output of project to parm at pt
data.CreateConnectorFromId(crvInputNodeId, crvInputIndex, parmAtPtId, 0);
data.CreateConnector(newNode, 0, parmAtPt, 1);
// reconnect remaining output ports to new nodes
var newTOut = new PortId(parmAtPtId, 0, PortType.OUTPUT);
oldUVConnectors.ToList().ForEach(x => data.ReconnectToPort(x, newTOut));
}
#endregion
#region Reconnect the old distance out port
var oldDOut = new PortId(newNodeId, 2, PortType.OUTPUT);
var oldDConnectors = data.FindConnectors(oldDOut);
// If necessary, get the distance to the projected point
if (oldDConnectors != null && oldDConnectors.Any())
{
// Get the original output ports connected to input
var ptInputNodeId = ptInConnector.Attributes["start"].Value;
var ptInputIndex = int.Parse(ptInConnector.Attributes["start_index"].Value);
// make distance to node
var distTo = MigrationManager.CreateFunctionNode(
data.Document, oldNode, 0, "ProtoGeometry.dll",
"Geometry.DistanceTo",
"[email protected]");
migrationData.AppendNode(distTo);
var distToId = MigrationManager.GetGuidFromXmlElement(distTo);
data.CreateConnector(newNode, 0, distTo, 0);
data.CreateConnectorFromId(ptInputNodeId, ptInputIndex, distToId, 1);
var newDOut = new PortId(distToId, 0, PortType.OUTPUT);
oldDConnectors.ToList().ForEach(x => data.ReconnectToPort(x, newDOut));
}
#endregion
return migrationData;
}
示例6: Migrate_0630_to_0700
public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
{
NodeMigrationData migrationData = new NodeMigrationData(data.Document);
XmlElement oldNode = data.MigratedNodes.ElementAt(0);
string oldNodeId = MigrationManager.GetGuidFromXmlElement(oldNode);
XmlElement newPointNode = MigrationManager.CreateFunctionNodeFrom(oldNode);
MigrationManager.SetFunctionSignature(newPointNode, "ProtoGeometry.dll",
"Point.ByCoordinates", "[email protected],double,double");
migrationData.AppendNode(newPointNode);
string newPointNodeId = MigrationManager.GetGuidFromXmlElement(newPointNode);
XmlElement getXNode = MigrationManager.CreateFunctionNode(data.Document, oldNode, 0,
"ProtoGeometry.dll", "Point.X", "Point.X");
XmlElement getYNode = MigrationManager.CreateFunctionNode(data.Document, oldNode, 1,
"ProtoGeometry.dll", "Point.Y", "Point.Y");
XmlElement getZNode = MigrationManager.CreateFunctionNode(data.Document, oldNode, 2,
"ProtoGeometry.dll", "Point.Z", "Point.Z");
migrationData.AppendNode(getXNode);
migrationData.AppendNode(getYNode);
migrationData.AppendNode(getZNode);
XmlElement xAverageNode = MigrationManager.CreateFunctionNode(data.Document, oldNode, 3,
"DSCoreNodes.dll", "Average", "[email protected][]");
XmlElement yAverageNode = MigrationManager.CreateFunctionNode(data.Document, oldNode, 4,
"DSCoreNodes.dll", "Average", "[email protected][]");
XmlElement zAverageNode = MigrationManager.CreateFunctionNode(data.Document, oldNode, 5,
"DSCoreNodes.dll", "Average", "[email protected][]");
migrationData.AppendNode(xAverageNode);
migrationData.AppendNode(yAverageNode);
migrationData.AppendNode(zAverageNode);
string getXNodeId = MigrationManager.GetGuidFromXmlElement(getXNode);
string getYNodeId = MigrationManager.GetGuidFromXmlElement(getYNode);
string getZNodeId = MigrationManager.GetGuidFromXmlElement(getZNode);
string xAverageNodeId = MigrationManager.GetGuidFromXmlElement(xAverageNode);
string yAverageNodeId = MigrationManager.GetGuidFromXmlElement(yAverageNode);
string zAverageNodeId = MigrationManager.GetGuidFromXmlElement(zAverageNode);
data.CreateConnector(getXNode, 0, xAverageNode, 0);
data.CreateConnector(getYNode, 0, yAverageNode, 0);
data.CreateConnector(getZNode, 0, zAverageNode, 0);
data.CreateConnector(xAverageNode, 0, newPointNode, 0);
data.CreateConnector(yAverageNode, 0, newPointNode, 1);
data.CreateConnector(zAverageNode, 0, newPointNode, 2);
PortId oldOutPort = new PortId(oldNodeId, 0, PortType.OUTPUT);
PortId newOutPort = new PortId(newPointNodeId, 0, PortType.OUTPUT);
var connectors = data.FindConnectors(oldOutPort);
if (null != connectors)
{
foreach (var connector in connectors)
{
data.ReconnectToPort(connector, newOutPort);
}
}
PortId oldInPort = new PortId(oldNodeId, 0, PortType.INPUT);
PortId newInPort0 = new PortId(getXNodeId, 0, PortType.INPUT);
PortId newInPort1 = new PortId(getYNodeId, 0, PortType.INPUT);
PortId newInPort2 = new PortId(getZNodeId, 0, PortType.INPUT);
var connector0 = data.FindFirstConnector(oldInPort);
if (null != connector0)
{
data.ReconnectToPort(connector0, newInPort0);
var connector1 = MigrationManager.CreateFunctionNodeFrom(connector0);
data.CreateConnector(connector1);
var connector2 = MigrationManager.CreateFunctionNodeFrom(connector0);
data.CreateConnector(connector2);
data.ReconnectToPort(connector1, newInPort1);
data.ReconnectToPort(connector2, newInPort2);
}
return migrationData;
}