Ejemplo n.º 1
0
        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", "Autodesk.DesignScript.Geometry.Curve.ParameterTrim@double,double");
            migrationData.AppendNode(newNode);
            string newNodeId = MigrationManager.GetGuidFromXmlElement(newNode);

            XmlElement startParam = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 0, "ProtoGeometry.dll",
                "Curve.ParameterAtPoint", "Curve.ParameterAtPoint@Point");

            migrationData.AppendNode(startParam);
            string startParamId = MigrationManager.GetGuidFromXmlElement(startParam);

            XmlElement endParam = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 1, "ProtoGeometry.dll",
                "Curve.ParameterAtPoint", "Curve.ParameterAtPoint@Point");

            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);
        }
Ejemplo n.º 2
0
        public void TestCreateConnectorFromId()
        {

            //Arrange
            //In the file Angle.dyn we have only two connectors
            NodeMigrationData migrationDataTest = null;
            string documentDynPath = Path.Combine(TestDirectory, @"core\Angle.dyn");
            XmlDocument xmlDoc = new XmlDocument();
            string startNodeId = Guid.NewGuid().ToString();
            string endNodeId = Guid.NewGuid().ToString();

            //Act
            xmlDoc.Load(documentDynPath);           

            migrationDataTest = new NodeMigrationData(xmlDoc);
            //Creates a connector from node1 to node2 (based in new generated id's)
            migrationDataTest.CreateConnectorFromId(startNodeId, 0, endNodeId, 0);

            //Assert
            //Verify that now we have three connectors (one is Dynamo.Models.ConnectorModel)
            Assert.AreEqual(xmlDoc.SelectNodes("//Connectors/*").Count, 3);

            //Verify that the node exists inside the Angle.dyn file
            var connectorCreated = xmlDoc.SelectSingleNode("//Connectors/Dynamo.Models.ConnectorModel[@start='"+ startNodeId + "'][@end='"+ endNodeId + "']");
            Assert.IsNotNull(connectorCreated);
        }
Ejemplo n.º 3
0
        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.NormalAtParameter", "Surface.NormalAtParameter@double,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);
        }
Ejemplo n.º 4
0
        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", "Line.ByStartPointEndPoint@Point,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, oldNode, 0, "ProtoGeometry.dll", "Geometry.Translate",
                    "*****@*****.**");
                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);
        }
Ejemplo n.º 5
0
        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", "Geometry.Intersect@Geometry");
            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);

            if (xyzConnects != null)
            {
                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, oldNode, 0, "ProtoGeometry.dll",
                    "Curve.ParameterAtPoint",
                    "Curve.ParameterAtPoint@Point");
                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, oldNode, 0, "ProtoGeometry.dll",
                    "Curve.ParameterAtPoint",
                    "Curve.ParameterAtPoint@Point");
                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;
        }
Ejemplo n.º 6
0
        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", "Geometry.Intersect@Geometry");
            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",
                    "Surface.UVParameterAtPoint@Point");
                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",
                    "Curve.ParameterAtPoint@Point");
                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)
                    oldTConnectors.ToList().ForEach(x => data.ReconnectToPort(x, newTOut));
            }

            return migrationData;
        }
Ejemplo n.º 7
0
        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", "List.Slice@var[]..[],int,int,int");
            migrationData.AppendNode(newNode);
            string newNodeId = MigrationManager.GetGuidFromXmlElement(newNode);

            XmlElement plus = MigrationManager.CreateFunctionNode(data.Document,
                oldNode, 0, "", "+", "+@,");
            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;
        }
Ejemplo n.º 8
0
        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", "Geometry.Intersect@Geometry");
            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);

            if (xyzConnects != null)
            {
                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, oldNode, 0, "ProtoGeometry.dll",
                    "Curve.ParameterAtPoint",
                    "Curve.ParameterAtPoint@Point");
                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, oldNode, 0, "ProtoGeometry.dll",
                    "Curve.ParameterAtPoint",
                    "Curve.ParameterAtPoint@Point");
                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);
        }
Ejemplo n.º 9
0
        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", "Geometry.Intersect@Geometry");
            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",
                    "Surface.UVParameterAtPoint@Point");
                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",
                    "Curve.ParameterAtPoint@Point");
                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)
                {
                    oldTConnectors.ToList().ForEach(x => data.ReconnectToPort(x, newTOut));
                }
            }

            return(migrationData);
        }
Ejemplo n.º 10
0
        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",
                "Geometry.ClosestPointTo", "Geometry.ClosestPointTo@Geometry");
            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);

            var oldDOut = new PortId(newNodeId, 2, PortType.Output);
            var oldTOut = new PortId(newNodeId, 1, PortType.Output);

            if ((connector0 != null) && (data.FindConnectors(oldDOut) != null))
            {
                // Get the original output ports connected to input
                var ptInputNodeId = connector0.Attributes["start"].Value;
                var ptInputIndex = int.Parse(connector0.Attributes["start_index"].Value);

                // make distance to node
                var distTo = MigrationManager.CreateFunctionNode(
                    data.Document, oldNode, 1, "ProtoGeometry.dll",
                    "Geometry.DistanceTo",
                    "Geometry.DistanceTo@Geometry");
                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);
                var oldDConnectors = data.FindConnectors(oldDOut);

                if (oldDConnectors != null)
                    oldDConnectors.ToList().ForEach(x => data.ReconnectToPort(x, newDOut));
            }

            if ((connector1 != null) && (data.FindConnectors(oldTOut) != 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, oldNode, 0, "ProtoGeometry.dll",
                    "Curve.ParameterAtPoint",
                    "Curve.ParameterAtPoint@Point");
                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 oldTConnectors = data.FindConnectors(oldTOut);

                if (oldTConnectors != null)
                    oldTConnectors.ToList().ForEach(x => data.ReconnectToPort(x, newTOut));
            }

            return migrationData;
        }
Ejemplo n.º 11
0
        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",
                "Surface.CoordinateSystemAtParameter", "Surface.CoordinateSystemAtParameter@double,double");
            migrationData.AppendNode(newNode);
            string newNodeId = MigrationManager.GetGuidFromXmlElement(newNode);

            // Update connectors
            PortId facePort = new PortId(newNodeId, 0, PortType.Input);
            PortId uvPort = new PortId(newNodeId, 1, PortType.Input);
            PortId newInPort0 = new PortId(newNodeId, 0, PortType.Input);

            XmlElement uvPortConnector = data.FindFirstConnector(uvPort);
            XmlElement facePortConnector = data.FindFirstConnector(facePort);

            data.ReconnectToPort(facePortConnector, newInPort0);

            if (uvPortConnector != 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 = uvPortConnector.GetAttribute("start").ToString();
                data.ReconnectToPort(uvPortConnector, newInPortNodeU);
                data.CreateConnector(nodeU, 0, newNode, 1);
                data.CreateConnector(nodeV, 0, newNode, 2);
                data.CreateConnectorFromId(nodeUVId, 0, nodeVId, 0);
            }

            return migrationData;
        }
Ejemplo n.º 12
0
        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", "Autodesk.DesignScript.Geometry.Curve.ParameterTrim@double,double");
            migrationData.AppendNode(newNode);
            string newNodeId = MigrationManager.GetGuidFromXmlElement(newNode);

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

            XmlElement endParam = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 1, "ProtoGeometry.dll",
                "Curve.ParameterAtPoint", "Curve.ParameterAtPoint@Point");
            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;
        }
Ejemplo n.º 13
0
        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", "Point.Add@Vector");
            migrationData.AppendNode(pointAdd);
            string pointAddId = MigrationManager.GetGuidFromXmlElement(pointAdd);

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

            XmlElement geometryScale = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 1, "ProtoGeometry.dll",
                "Geometry.Scale", "Geometry.Scale@double");
            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;
        }
Ejemplo n.º 14
0
        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            NodeMigrationData migrationData = new NodeMigrationData(data.Document);

            #region Create new DSFunction node - Geometry.ClosestPointTo@Geometry

            XmlElement oldNode = data.MigratedNodes.ElementAt(0);
            var newNode = MigrationManager.CreateFunctionNodeFrom(oldNode);
            MigrationManager.SetFunctionSignature(newNode, "ProtoGeometry.dll",
                "Geometry.ClosestPointTo", "Geometry.ClosestPointTo@Geometry");
            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",
                    "Surface.UVParameterAtPoint@Point");
                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",
                    "Geometry.DistanceTo@Geometry");
                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;
        }
Ejemplo n.º 15
0
        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",
                                                  "Geometry.GetClosestPoint", "Geometry.GetClosestPoint@Geometry");
            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);

            if (connector0 != null)
            {
                // Get the original output ports connected to input
                var ptInputNodeId = connector0.Attributes["start"].Value;
                var ptInputIndex  = int.Parse(connector0.Attributes["start_index"].Value);

                // make distance to node
                var distTo = MigrationManager.CreateFunctionNode(
                    data.Document, oldNode, 0, "ProtoGeometry.dll",
                    "Geometry.DistanceTo",
                    "Geometry.DistanceTo@Geometry");
                migrationData.AppendNode(distTo);
                var distToId = MigrationManager.GetGuidFromXmlElement(distTo);

                data.CreateConnector(newNode, 0, distTo, 0);
                data.CreateConnectorFromId(ptInputNodeId, ptInputIndex, distToId, 1);

                var oldDOut        = new PortId(newNodeId, 2, PortType.OUTPUT);
                var newDOut        = new PortId(distToId, 0, PortType.OUTPUT);
                var oldDConnectors = data.FindConnectors(oldDOut);
                oldDConnectors.ToList().ForEach(x => data.ReconnectToPort(x, newDOut));
            }

            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, oldNode, 0, "ProtoGeometry.dll",
                    "Curve.ParameterAtPoint",
                    "Curve.ParameterAtPoint@Point");
                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, 1, PortType.OUTPUT);

                var oldTConnectors = data.FindConnectors(oldTOut);

                oldTConnectors.ToList().ForEach(x => data.ReconnectToPort(x, newTOut));
            }

            return(migrationData);
        }
Ejemplo n.º 16
0
        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            NodeMigrationData migrationData = new NodeMigrationData(data.Document);

            #region Create new DSFunction node - Geometry.GetClosestPoint@Geometry

            XmlElement oldNode = data.MigratedNodes.ElementAt(0);
            var        newNode = MigrationManager.CreateFunctionNodeFrom(oldNode);
            MigrationManager.SetFunctionSignature(newNode, "ProtoGeometry.dll",
                                                  "Geometry.GetClosestPoint", "Geometry.GetClosestPoint@Geometry");
            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",
                    "Surface.UVParameterAtPoint@Point");
                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",
                    "Geometry.DistanceTo@Geometry");
                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);
        }
Ejemplo n.º 17
0
        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", "Line.ByStartPointEndPoint@Point,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, oldNode, 0, "ProtoGeometry.dll", "Geometry.Translate",
                    "*****@*****.**");
                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;
        }