当前位置: 首页>>代码示例>>C#>>正文


C# NodeMigrationData.CreateConnectorFromId方法代码示例

本文整理汇总了C#中Dynamo.Models.NodeMigrationData.CreateConnectorFromId方法的典型用法代码示例。如果您正苦于以下问题:C# NodeMigrationData.CreateConnectorFromId方法的具体用法?C# NodeMigrationData.CreateConnectorFromId怎么用?C# NodeMigrationData.CreateConnectorFromId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dynamo.Models.NodeMigrationData的用法示例。


在下文中一共展示了NodeMigrationData.CreateConnectorFromId方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Migrate_0630_to_0700

        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            NodeMigrationData migrationData = new NodeMigrationData(data.Document);

            // Create DSFunction node
            XmlElement oldNode = data.MigratedNodes.ElementAt(0);
            var newNode = MigrationManager.CreateFunctionNodeFrom(oldNode);
            MigrationManager.SetFunctionSignature(newNode, "ProtoGeometry.dll",
                "Line.ByStartPointEndPoint", "[email protected],Point");
            migrationData.AppendNode(newNode);
            string newNodeId = MigrationManager.GetGuidFromXmlElement(newNode);

            // Update connectors
            PortId oldInPort0 = new PortId(newNodeId, 0, PortType.INPUT);
            PortId oldInPort1 = new PortId(newNodeId, 1, PortType.INPUT);
            PortId newInPort0 = new PortId(newNodeId, 0, PortType.INPUT);
            XmlElement connector0 = data.FindFirstConnector(oldInPort0);
            XmlElement connector1 = data.FindFirstConnector(oldInPort1);

            data.ReconnectToPort(connector1, newInPort0);

            if (connector1 != null)
            {
                // Create new node only when the old node is connected to a normal vector
                XmlElement translateNode = MigrationManager.CreateFunctionNode(
                    data.Document, "ProtoGeometry.dll", "Geometry.Translate",
                    "[email protected]");
                migrationData.AppendNode(translateNode);
                string translateNodeId = MigrationManager.GetGuidFromXmlElement(translateNode);

                // Update connectors
                PortId newInPortTranslate1 = new PortId(translateNodeId, 1, PortType.INPUT);

                string nodeOriginId = connector1.GetAttribute("start").ToString();
                data.CreateConnector(translateNode, 0, newNode, 1);
                data.CreateConnectorFromId(nodeOriginId, 0, translateNodeId, 0);
                data.ReconnectToPort(connector0, newInPortTranslate1);
            }

            return migrationData;
        }
开发者ID:TheChosen0ne,项目名称:Dynamo,代码行数:41,代码来源:Line.cs

示例2: 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;
        }
开发者ID:TheChosen0ne,项目名称:Dynamo,代码行数:83,代码来源:Intersect.cs

示例3: 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);

            // Create nodes
            XmlElement newNode = MigrationManager.CreateFunctionNodeFrom(oldNode);
            MigrationManager.SetFunctionSignature(newNode, "DSCoreNodes.dll",
                "List.Slice", "[email protected][]..[],int,int,int");
            migrationData.AppendNode(newNode);
            string newNodeId = MigrationManager.GetGuidFromXmlElement(newNode);

            XmlElement plus = MigrationManager.CreateFunctionNode(data.Document,
                oldNode, 0, "", "+", "[email protected],");
            migrationData.AppendNode(plus);
            string plusId = MigrationManager.GetGuidFromXmlElement(plus);

            // Update connectors
            PortId oldInPort0 = new PortId(oldNodeId, 0, PortType.INPUT);
            PortId oldInPort1 = new PortId(oldNodeId, 1, PortType.INPUT);
            PortId oldInPort2 = new PortId(oldNodeId, 2, PortType.INPUT);
            XmlElement connector0 = data.FindFirstConnector(oldInPort0);
            XmlElement connector1 = data.FindFirstConnector(oldInPort1);
            XmlElement connector2 = data.FindFirstConnector(oldInPort2);

            PortId newInPort0 = new PortId(newNodeId, 0, PortType.INPUT);
            PortId newInPort1 = new PortId(newNodeId, 1, PortType.INPUT);
            PortId plusInPort1 = new PortId(plusId, 1, PortType.INPUT);

            if (connector0 != null)
            {
                string startId = connector0.GetAttribute("start");
                data.CreateConnectorFromId(startId, 0, plusId, 0);
            }

            data.ReconnectToPort(connector0, newInPort1);
            data.ReconnectToPort(connector1, plusInPort1);
            data.ReconnectToPort(connector2, newInPort0);
            data.CreateConnector(plus, 0, newNode, 2);

            // Add default value
            XmlElement defaultValue = data.Document.CreateElement("PortInfo");
            defaultValue.SetAttribute("index", "3");
            defaultValue.SetAttribute("default", "True");
            newNode.AppendChild(defaultValue);

            return migrationData;
        }
开发者ID:RobertiF,项目名称:Dynamo,代码行数:49,代码来源:dynBaseTypes.cs

示例4: Migrate_0630_to_0700

        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            NodeMigrationData migrationData = new NodeMigrationData(data.Document);

            // Create DSFunction node
            XmlElement oldNode = data.MigratedNodes.ElementAt(0);
            var pointAdd = MigrationManager.CreateFunctionNodeFrom(oldNode);
            MigrationManager.SetFunctionSignature(pointAdd, "ProtoGeometry.dll",
                "Point.Add", "[email protected]");
            migrationData.AppendNode(pointAdd);
            string pointAddId = MigrationManager.GetGuidFromXmlElement(pointAdd);

            // Create new nodes
            XmlElement vectorDiff = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 0, "ProtoGeometry.dll",
                "Vector.ByTwoPoints", "[email protected],Point");
            migrationData.AppendNode(vectorDiff);
            string vectorDiffId = MigrationManager.GetGuidFromXmlElement(vectorDiff);

            XmlElement geometryScale = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 1, "ProtoGeometry.dll",
                "Geometry.Scale", "[email protected]");
            migrationData.AppendNode(geometryScale);
            string geometryScaleId = MigrationManager.GetGuidFromXmlElement(geometryScale);

            // Update connectors
            PortId oldInPort0 = new PortId(pointAddId, 0, PortType.INPUT);
            PortId oldInPort1 = new PortId(pointAddId, 1, PortType.INPUT);
            PortId oldInPort2 = new PortId(pointAddId, 2, PortType.INPUT);
            XmlElement connector0 = data.FindFirstConnector(oldInPort0);
            XmlElement connector1 = data.FindFirstConnector(oldInPort1);
            XmlElement connector2 = data.FindFirstConnector(oldInPort2);

            PortId geometryScaleInPort1 = new PortId(geometryScaleId, 1, PortType.INPUT);
            PortId vectorDiffInPort0 = new PortId(vectorDiffId, 0, PortType.INPUT);
            PortId vectorDiffInPort1 = new PortId(vectorDiffId, 1, PortType.INPUT);

            data.ReconnectToPort(connector0, vectorDiffInPort1);
            data.ReconnectToPort(connector1, geometryScaleInPort1);
            data.ReconnectToPort(connector2, vectorDiffInPort0);
            data.CreateConnector(vectorDiff, 0, geometryScale, 0);
            data.CreateConnector(geometryScale, 0, pointAdd, 1);

            if (connector2 != null)
            {
                string baseInputId = connector2.GetAttribute("start").ToString();
                data.CreateConnectorFromId(baseInputId, 0, pointAddId, 0);
            }

            return migrationData;
        }
开发者ID:RobertiF,项目名称:Dynamo,代码行数:51,代码来源:XYZ.cs

示例5: Migrate_0630_to_0700

        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            NodeMigrationData migrationData = new NodeMigrationData(data.Document);

            // Create nodes
            XmlElement oldNode = data.MigratedNodes.ElementAt(0);
            var newNode = MigrationManager.CreateFunctionNodeFrom(oldNode);
            MigrationManager.SetFunctionSignature(newNode, "ProtoGeometry.dll",
                "Curve.ParameterTrim", "[email protected],double");
            migrationData.AppendNode(newNode);
            string newNodeId = MigrationManager.GetGuidFromXmlElement(newNode);

            XmlElement startParam = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 0, "ProtoGeometry.dll",
                "Curve.ParameterAtPoint", "[email protected]");
            migrationData.AppendNode(startParam);
            string startParamId = MigrationManager.GetGuidFromXmlElement(startParam);

            XmlElement endParam = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 1, "ProtoGeometry.dll",
                "Curve.ParameterAtPoint", "[email protected]");
            migrationData.AppendNode(endParam);
            string endParamId = MigrationManager.GetGuidFromXmlElement(endParam);

            // Update connectors
            PortId oldInPort0 = new PortId(newNodeId, 0, PortType.INPUT);
            PortId oldInPort1 = new PortId(newNodeId, 1, PortType.INPUT);
            PortId oldInPort2 = new PortId(newNodeId, 2, PortType.INPUT);
            PortId startParamInPort = new PortId(startParamId, 1, PortType.INPUT);
            PortId endParamInPort = new PortId(endParamId, 1, PortType.INPUT);
            XmlElement connector0 = data.FindFirstConnector(oldInPort0);
            XmlElement connector1 = data.FindFirstConnector(oldInPort1);
            XmlElement connector2 = data.FindFirstConnector(oldInPort2);

            data.ReconnectToPort(connector1, startParamInPort);
            data.ReconnectToPort(connector2, endParamInPort);
            data.CreateConnector(startParam, 0, newNode, 1);
            data.CreateConnector(endParam, 0, newNode, 2);
            
            if (connector0 != null)
            {
                string curveInputId = connector0.GetAttribute("start").ToString();
                data.CreateConnectorFromId(curveInputId, 0, startParamId, 0);
                data.CreateConnectorFromId(curveInputId, 0, endParamId, 0);
            }
            
            return migrationData;
        }
开发者ID:RobertiF,项目名称:Dynamo,代码行数:48,代码来源:Curve.cs

示例6: 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)
//.........这里部分代码省略.........
开发者ID:rafatahmed,项目名称:Dynamo,代码行数:101,代码来源:Intersect.cs

示例7: Migrate_0630_to_0700

        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            NodeMigrationData migrationData = new NodeMigrationData(data.Document);

            // Create DSFunction node
            XmlElement oldNode = data.MigratedNodes.ElementAt(0);
            var newNode = MigrationManager.CreateFunctionNodeFrom(oldNode);
            MigrationManager.SetFunctionSignature(newNode, "ProtoGeometry.dll",
                "Surface.PointAtParameter", "[email protected],double");
            migrationData.AppendNode(newNode);
            string newNodeId = MigrationManager.GetGuidFromXmlElement(newNode);

            // Update connectors
            PortId oldInPort0 = new PortId(newNodeId, 0, PortType.INPUT);
            PortId oldInPort1 = new PortId(newNodeId, 1, PortType.INPUT);
            PortId newInPort0 = new PortId(newNodeId, 0, PortType.INPUT);
            
            XmlElement connector0 = data.FindFirstConnector(oldInPort0);
            XmlElement connector1 = data.FindFirstConnector(oldInPort1);

            data.ReconnectToPort(connector1, newInPort0);

            if (connector0 != null)
            {
                // Create new nodes only when the old node is connected to a UV node
                XmlElement nodeU = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 0, "ProtoGeometry.dll", "UV.U", "UV.U");
                migrationData.AppendNode(nodeU);
                string nodeUId = MigrationManager.GetGuidFromXmlElement(nodeU);

                XmlElement nodeV = MigrationManager.CreateFunctionNode(
                    data.Document, oldNode, 1, "ProtoGeometry.dll", "UV.V", "UV.V");
                migrationData.AppendNode(nodeV);
                string nodeVId = MigrationManager.GetGuidFromXmlElement(nodeV);

                // Update connectors
                PortId newInPortNodeU = new PortId(nodeUId, 0, PortType.INPUT);

                string nodeUVId = connector0.GetAttribute("start").ToString();
                data.ReconnectToPort(connector0, newInPortNodeU);
                data.CreateConnector(nodeU, 0, newNode, 1);
                data.CreateConnector(nodeV, 0, newNode, 2);
                data.CreateConnectorFromId(nodeUVId, 0, nodeVId, 0);
            }
            
            return migrationData;
        }
开发者ID:algobasket,项目名称:Dynamo,代码行数:47,代码来源:Face.cs

示例8: 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;
        }
开发者ID:whztt07,项目名称:Dynamo,代码行数:83,代码来源:Project.cs

示例9: Migrate_0630_to_0700

        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            NodeMigrationData migrationData = new NodeMigrationData(data.Document);

            // Create DSFunction node
            XmlElement oldNode = data.MigratedNodes.ElementAt(0);
            string oldNodeId = MigrationManager.GetGuidFromXmlElement(oldNode);

            var newNode = MigrationManager.CreateFunctionNodeFrom(oldNode);
            MigrationManager.SetFunctionSignature(newNode, "ProtoGeometry.dll",
                "CoordinateSystem.PostMultiplyBy",
                "[email protected]");
            migrationData.AppendNode(newNode);
            string newNodeId = MigrationManager.GetGuidFromXmlElement(newNode);

            // Create new nodes
            XmlElement vectorCrossFrom = MigrationManager.CreateFunctionNode(
                data.Document, "ProtoGeometry.dll",
                "Vector.Cross", "[email protected]");
            migrationData.AppendNode(vectorCrossFrom);
            string vectorCrossFromId = MigrationManager.GetGuidFromXmlElement(vectorCrossFrom);

            XmlElement vectorCrossTo = MigrationManager.CreateFunctionNode(
                data.Document, "ProtoGeometry.dll",
                "Vector.Cross", "[email protected]");
            migrationData.AppendNode(vectorCrossTo);
            string vectorCrossToId = MigrationManager.GetGuidFromXmlElement(vectorCrossTo);

            XmlElement csFrom = MigrationManager.CreateFunctionNode(
                data.Document, "ProtoGeometry.dll", "CoordinateSystem.ByOriginVectors",
                "[email protected]Point,"
                + "Autodesk.DesignScript.Geometry.Vector,Autodesk.DesignScript.Geometry"
                + ".Vector,Autodesk.DesignScript.Geometry.Vector");
            string csFromId = MigrationManager.GetGuidFromXmlElement(csFrom);
            migrationData.AppendNode(csFrom);

            XmlElement csTo = MigrationManager.CreateFunctionNode(
                data.Document, "ProtoGeometry.dll", "CoordinateSystem.ByOriginVectors",
                "[email protected]Point,"
                + "Autodesk.DesignScript.Geometry.Vector,Autodesk.DesignScript.Geometry"
                + ".Vector,Autodesk.DesignScript.Geometry.Vector");
            string csToId = MigrationManager.GetGuidFromXmlElement(csTo);
            migrationData.AppendNode(csTo);

            XmlElement csInverse = MigrationManager.CreateFunctionNode(
                data.Document, "ProtoGeometry.dll",
                "CoordinateSystem.Inverse", "CoordinateSystem.Inverse");
            migrationData.AppendNode(csInverse);

            // Update connectors
            PortId csFrom0 = new PortId(csFromId, 0, PortType.INPUT);
            PortId csFrom1 = new PortId(csFromId, 1, PortType.INPUT);
            PortId csFrom2 = new PortId(csFromId, 2, PortType.INPUT);
            PortId csFrom3 = new PortId(csFromId, 3, PortType.INPUT);
            PortId csTo0 = new PortId(csToId, 0, PortType.INPUT);
            PortId csTo1 = new PortId(csToId, 1, PortType.INPUT);
            PortId csTo2 = new PortId(csToId, 2, PortType.INPUT);
            PortId csTo3 = new PortId(csToId, 3, PortType.INPUT);

            PortId oldInPort0 = new PortId(newNodeId, 0, PortType.INPUT);
            PortId oldInPort1 = new PortId(newNodeId, 1, PortType.INPUT);
            PortId oldInPort2 = new PortId(newNodeId, 2, PortType.INPUT);
            PortId oldInPort3 = new PortId(newNodeId, 3, PortType.INPUT);
            PortId oldInPort4 = new PortId(newNodeId, 4, PortType.INPUT);
            PortId oldInPort5 = new PortId(newNodeId, 5, PortType.INPUT);

            XmlElement connector0 = data.FindFirstConnector(oldInPort0);
            XmlElement connector1 = data.FindFirstConnector(oldInPort1);
            XmlElement connector2 = data.FindFirstConnector(oldInPort2);
            XmlElement connector3 = data.FindFirstConnector(oldInPort3);
            XmlElement connector4 = data.FindFirstConnector(oldInPort4);
            XmlElement connector5 = data.FindFirstConnector(oldInPort5);

            if (connector1 != null)
            {
                string uFromId = connector1.GetAttribute("start").ToString();
                data.CreateConnectorFromId(uFromId, 0, vectorCrossFromId, 1);
            }

            if (connector2 != null)
            {
                string fFromId = connector2.GetAttribute("start").ToString();
                data.CreateConnectorFromId(fFromId, 0, vectorCrossFromId, 0);
            }

            if (connector4 != null)
            {
                string uToId = connector4.GetAttribute("start").ToString();
                data.CreateConnectorFromId(uToId, 0, vectorCrossToId, 1);
            }

            if (connector5 != null)
            {
                string fToId = connector5.GetAttribute("start").ToString();
                data.CreateConnectorFromId(fToId, 0, vectorCrossToId, 0);
            }

            data.ReconnectToPort(connector0, csFrom0);
            data.ReconnectToPort(connector1, csFrom3);
            data.ReconnectToPort(connector2, csFrom2);
//.........这里部分代码省略.........
开发者ID:TheChosen0ne,项目名称:Dynamo,代码行数:101,代码来源:Transform.cs


注:本文中的Dynamo.Models.NodeMigrationData.CreateConnectorFromId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。