Exemple #1
0
        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            NodeMigrationData migrationData = new NodeMigrationData(data.Document);

            XmlElement oldNode = data.MigratedNodes.ElementAt(0);
            var        newNode = MigrationManager.CreateFunctionNodeFrom(oldNode);

            MigrationManager.SetFunctionSignature(newNode, "Tessellation.dll",
                                                  "ConvexHull.ByPoints",
                                                  "ConvexHull.ByPoints@IEnumerable<Point>");
            newNode.SetAttribute("lacing", "Shortest");
            migrationData.AppendNode(newNode);

            return(migrationData);
        }
Exemple #2
0
        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            NodeMigrationData migrationData = new NodeMigrationData(data.Document);

            XmlElement oldNode = data.MigratedNodes.ElementAt(0);
            var        newNode = MigrationManager.CreateFunctionNodeFrom(oldNode);

            MigrationManager.SetFunctionSignature(newNode, "Tessellation.dll",
                                                  "Delaunay.ByParametersOnSurface",
                                                  "Delaunay.ByParametersOnSurface@IEnumerable<UV>,Surface");
            newNode.SetAttribute("lacing", "Shortest");
            migrationData.AppendNode(newNode);

            return(migrationData);
        }
Exemple #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);
        }
Exemple #4
0
        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            NodeMigrationData migratedData = new NodeMigrationData(data.Document);
            XmlElement        oldNode      = data.MigratedNodes.ElementAt(0);
            string            oldNodeId    = MigrationManager.GetGuidFromXmlElement(oldNode);

            //create the node itself
            XmlElement dsRevitNode = MigrationManager.CreateFunctionNodeFrom(oldNode);

            MigrationManager.SetFunctionSignature(dsRevitNode, "RevitNodes.dll",
                                                  "Form.ByLoftingCurveElements",
                                                  "Form.ByLoftingCurveElements@CurveElement[],bool");

            migratedData.AppendNode(dsRevitNode);
            string dsRevitNodeId = MigrationManager.GetGuidFromXmlElement(dsRevitNode);

            //create and reconnect the connecters
            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(dsRevitNodeId, 0, PortType.INPUT);
            PortId newInPort1 = new PortId(dsRevitNodeId, 1, PortType.INPUT);

            data.ReconnectToPort(connector0, newInPort1);
            data.ReconnectToPort(connector1, newInPort0);

            // Add default values
            foreach (XmlNode child in oldNode.ChildNodes)
            {
                var newChild = child.Clone() as XmlElement;

                switch (newChild.GetAttribute("index"))
                {
                case "0":
                    newChild.SetAttribute("index", "1");
                    dsRevitNode.AppendChild(newChild);
                    break;

                default:
                    break;
                }
            }

            return(migratedData);
        }
Exemple #5
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);

            var newNode = MigrationManager.CreateFunctionNodeFrom(oldNode);

            MigrationManager.SetFunctionSignature(newNode, "RevitNodes.dll",
                                                  "Solid.BoxByCenterAndDimensions",
                                                  "Solid.BoxByCenterAndDimensions@Point,double,double,double");

            migrationData.AppendNode(newNode);

            // Add default values
            foreach (XmlNode child in oldNode.ChildNodes)
            {
                var newChild = child.Clone() as XmlElement;

                switch (newChild.GetAttribute("index"))
                {
                case "0":
                    PortId     oldInPort0 = new PortId(oldNodeId, 0, PortType.INPUT);
                    XmlElement connector0 = data.FindFirstConnector(oldInPort0);
                    if (connector0 != null)
                    {
                        break;
                    }

                    XmlElement cbn = MigrationManager.CreateCodeBlockNodeModelNode(
                        data.Document, oldNode, 0, "Point.ByCoordinates(0,0,0);");
                    migrationData.AppendNode(cbn);
                    data.CreateConnector(cbn, 0, newNode, 0);
                    break;

                case "1":
                case "2":
                case "3":
                    newNode.AppendChild(newChild);
                    break;

                default:
                    break;
                }
            }

            return(migrationData);
        }
Exemple #6
0
        protected static NodeMigrationData MigrateToDsFunction(
            NodeMigrationData data, string assembly, string nickname, string funcName)
        {
            XmlElement xmlNode = data.MigratedNodes.ElementAt(0);
            var        element = MigrationManager.CreateFunctionNodeFrom(xmlNode);

            element.SetAttribute("assembly", assembly);
            element.SetAttribute("nickname", nickname);
            element.SetAttribute("function", funcName);
            element.SetAttribute("lacing", xmlNode.Attributes["lacing"].Value);

            NodeMigrationData migrationData = new NodeMigrationData(data.Document);

            migrationData.AppendNode(element);
            return(migrationData);
        }
Exemple #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);

            XmlElement codeBlockNode = MigrationManager.CreateCodeBlockNodeModelNode(
                data.Document, oldNode, 0,
                "dom[0][0]+Math.RandomList\n" +
                "(ucount*vcount)\n" +
                "*(dom[1][0]-dom[0][0]);\n" +
                "dom[0][1]+Math.RandomList\n" +
                "(ucount*vcount)\n" +
                "*(dom[1][1]-dom[0][1]);");

            codeBlockNode.SetAttribute("nickname", "Random UV");
            migrationData.AppendNode(codeBlockNode);
            string codeBlockNodeId = MigrationManager.GetGuidFromXmlElement(codeBlockNode);

            XmlElement uvNode = MigrationManager.CreateFunctionNodeFrom(oldNode);

            MigrationManager.SetFunctionSignature(uvNode, "ProtoGeometry.dll",
                                                  "UV.ByCoordinates", "UV.ByCoordinates@double,double");
            uvNode.SetAttribute("lacing", "Longest");
            migrationData.AppendNode(uvNode);

            // 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);
            PortId     newInPort0 = new PortId(codeBlockNodeId, 0, PortType.Input);
            PortId     newInPort1 = new PortId(codeBlockNodeId, 1, PortType.Input);
            PortId     newInPort2 = new PortId(codeBlockNodeId, 2, PortType.Input);
            XmlElement connector0 = data.FindFirstConnector(oldInPort0);
            XmlElement connector1 = data.FindFirstConnector(oldInPort1);
            XmlElement connector2 = data.FindFirstConnector(oldInPort2);

            data.ReconnectToPort(connector0, newInPort0);
            data.ReconnectToPort(connector1, newInPort1);
            data.ReconnectToPort(connector2, newInPort2);

            data.CreateConnector(codeBlockNode, 0, uvNode, 0);
            data.CreateConnector(codeBlockNode, 1, uvNode, 1);

            return(migrationData);
        }
Exemple #8
0
        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            NodeMigrationData migratedData = new NodeMigrationData(data.Document);
            XmlElement        oldNode      = data.MigratedNodes.ElementAt(0);
            string            oldNodeId    = MigrationManager.GetGuidFromXmlElement(oldNode);

            //create the node itself
            XmlElement distanceToPoint = MigrationManager.CreateFunctionNodeFrom(oldNode);

            MigrationManager.SetFunctionSignature(distanceToPoint, "ProtoGeometry.dll",
                                                  "Geometry.DistanceTo",
                                                  "*****@*****.**");
            migratedData.AppendNode(distanceToPoint);
            string distanceToPointId = MigrationManager.GetGuidFromXmlElement(distanceToPoint);

            XmlElement point1 = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 0, "RevitNodes.dll",
                "ReferencePoint.Point", "ReferencePoint.Point");

            migratedData.AppendNode(point1);
            string point1Id = MigrationManager.GetGuidFromXmlElement(point1);

            XmlElement point2 = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 1, "RevitNodes.dll",
                "ReferencePoint.Point", "ReferencePoint.Point");

            migratedData.AppendNode(point2);
            string point2Id = MigrationManager.GetGuidFromXmlElement(point2);


            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(point1Id, 0, PortType.INPUT);
            PortId newInPort1 = new PortId(point2Id, 0, PortType.INPUT);

            data.ReconnectToPort(connector0, newInPort0);
            data.ReconnectToPort(connector1, newInPort1);

            data.CreateConnector(point1, 0, distanceToPoint, 0);
            data.CreateConnector(point2, 0, distanceToPoint, 1);

            return(migratedData);
        }
Exemple #9
0
        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            NodeMigrationData migratedData = new NodeMigrationData(data.Document);
            XmlElement        oldNode      = data.MigratedNodes.ElementAt(0);
            string            oldNodeId    = MigrationManager.GetGuidFromXmlElement(oldNode);

            //create the node itself
            XmlElement dsRevitNode = MigrationManager.CreateFunctionNodeFrom(oldNode);

            MigrationManager.SetFunctionSignature(dsRevitNode, "RevitNodes.dll",
                                                  "PerspectiveView.ByEyePointAndTarget",
                                                  "PerspectiveView.ByEyePointAndTarget@Point,Point,var,string,bool");

            migratedData.AppendNode(dsRevitNode);
            string dsRevitNodeId = MigrationManager.GetGuidFromXmlElement(dsRevitNode);

            //create and reconnect the connecters
            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     oldInPort2 = new PortId(oldNodeId, 2, PortType.INPUT);
            XmlElement connector2 = data.FindFirstConnector(oldInPort2);

            PortId     oldInPort3 = new PortId(oldNodeId, 3, PortType.INPUT);
            XmlElement connector3 = data.FindFirstConnector(oldInPort3);

            PortId     oldInPort4 = new PortId(oldNodeId, 4, PortType.INPUT);
            XmlElement connector4 = data.FindFirstConnector(oldInPort4);

            PortId newInPort0 = new PortId(dsRevitNodeId, 0, PortType.INPUT);
            PortId newInPort1 = new PortId(dsRevitNodeId, 1, PortType.INPUT);
            PortId newInPort2 = new PortId(dsRevitNodeId, 2, PortType.INPUT);
            PortId newInPort3 = new PortId(dsRevitNodeId, 3, PortType.INPUT);
            PortId newInPort4 = new PortId(dsRevitNodeId, 4, PortType.INPUT);

            data.ReconnectToPort(connector0, newInPort0);
            data.ReconnectToPort(connector1, newInPort1);
            data.ReconnectToPort(connector2, newInPort3);
            data.ReconnectToPort(connector3, newInPort2);
            data.ReconnectToPort(connector4, newInPort4);

            return(migratedData);
        }
Exemple #10
0
        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            NodeMigrationData migrationData = new NodeMigrationData(data.Document);
            XmlElement oldNode = data.MigratedNodes.ElementAt(0);

            var newNode = MigrationManager.CreateFunctionNodeFrom(oldNode);
            MigrationManager.SetFunctionSignature(newNode, "DSCoreNodes.dll",
                "Color.ByARGB", "Color.ByARGB@int,int,int,int");

            migrationData.AppendNode(newNode);

            // Add default values
            foreach (XmlNode child in oldNode.ChildNodes)
                newNode.AppendChild(child.Clone());

            return migrationData;
        }
Exemple #11
0
        public void CreateFunctionNodeFrom07()
        {
            XmlElement srcElement = xmlDocument.CreateElement("Element");

            srcElement.SetAttribute("one", "1");
            srcElement.SetAttribute("two", "2");
            srcElement.SetAttribute("three", "3");

            XmlElement dstElement = MigrationManager.CreateFunctionNodeFrom(srcElement);

            Assert.IsNotNull(dstElement);
            Assert.IsNotNull(dstElement.Attributes);
            Assert.AreEqual(4, dstElement.Attributes.Count);
            Assert.AreEqual("1", dstElement.Attributes["one"].Value);
            Assert.AreEqual("2", dstElement.Attributes["two"].Value);
            Assert.AreEqual("3", dstElement.Attributes["three"].Value);
            Assert.AreEqual("Dynamo.Nodes.DSFunction", dstElement.Attributes["type"].Value);
        }
Exemple #12
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);
            string     oldNodeId = MigrationManager.GetGuidFromXmlElement(oldNode);

            var newNode = MigrationManager.CreateFunctionNodeFrom(oldNode);

            MigrationManager.SetFunctionSignature(newNode, "ProtoGeometry.dll",
                                                  "CoordinateSystem.Translate",
                                                  "*****@*****.**");
            migrationData.AppendNode(newNode);
            string newNodeId = MigrationManager.GetGuidFromXmlElement(newNode);

            // Create new node
            XmlElement identityCoordinateSystem = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 0, "ProtoGeometry.dll",
                "CoordinateSystem.Identity",
                "CoordinateSystem.Identity");

            migrationData.AppendNode(identityCoordinateSystem);

            //append asVector Node
            XmlElement pointAsVector0 = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 1, "ProtoGeometry.dll",
                "Point.AsVector", "Point.AsVector");

            migrationData.AppendNode(pointAsVector0);
            string pointAsVector0Id = MigrationManager.GetGuidFromXmlElement(pointAsVector0);

            // Update connectors
            PortId     oldInPort0 = new PortId(newNodeId, 0, PortType.Input);
            PortId     newInPort1 = new PortId(newNodeId, 1, PortType.Input);
            XmlElement connector0 = data.FindFirstConnector(oldInPort0);
            PortId     pToV0      = new PortId(pointAsVector0Id, 0, PortType.Input);

            data.ReconnectToPort(connector0, pToV0);
            data.CreateConnector(pointAsVector0, 0, newNode, 1);
            data.CreateConnector(identityCoordinateSystem, 0, newNode, 0);

            return(migrationData);
        }
Exemple #13
0
        public void CreateFunctionNodeFrom04()
        {
            XmlElement srcElement = xmlDocument.CreateElement("Element");

            srcElement.SetAttribute("guid", "D514AA10-63F0-4479-BB9F-0FEBEB2274B0");

            // Non-existence attribute will result in a same-name attribute
            // in the resulting XmlElement with an empty value.
            XmlElement dstElement = MigrationManager.CreateFunctionNodeFrom(
                srcElement, new string[] { "guid", "dummy" });

            Assert.IsNotNull(dstElement);
            Assert.AreEqual(3, dstElement.Attributes.Count);
            Assert.AreEqual("D514AA10-63F0-4479-BB9F-0FEBEB2274B0",
                            dstElement.Attributes["guid"].Value);

            Assert.AreEqual("", dstElement.Attributes["dummy"].Value);
            Assert.AreEqual("Dynamo.Graph.Nodes.ZeroTouch.DSFunction", dstElement.Attributes["type"].Value);
        }
Exemple #14
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");
            newNode.SetAttribute("lacing", "Shortest");
            migrationData.AppendNode(newNode);
            string newNodeId = MigrationManager.GetGuidFromXmlElement(newNode);

            // Create new nodes
            XmlElement reverse = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 0, "DSCoreNodes.dll",
                "List.Reverse",
                "List.Reverse@var[]..[]");

            migrationData.AppendNode(reverse);
            string reverseId = MigrationManager.GetGuidFromXmlElement(reverse);

            XmlElement rest = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 1, "DSCoreNodes.dll",
                "List.RestOfItems",
                "List.RestOfItems@var[]..[]");

            migrationData.AppendNode(rest);

            // Update connectors
            PortId     oldInPort0     = new PortId(newNodeId, 0, PortType.INPUT);
            XmlElement connector0     = data.FindFirstConnector(oldInPort0);
            PortId     reverseInPort0 = new PortId(reverseId, 0, PortType.INPUT);

            data.ReconnectToPort(connector0, reverseInPort0);
            data.CreateConnector(reverse, 0, newNode, 0);
            data.CreateConnector(reverse, 0, rest, 0);
            data.CreateConnector(rest, 0, newNode, 1);

            return(migrationData);
        }
Exemple #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",
                                                  "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);
        }
Exemple #16
0
        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            NodeMigrationData migratedData = new NodeMigrationData(data.Document);
            XmlElement        oldNode      = data.MigratedNodes.ElementAt(0);
            string            oldNodeId    = MigrationManager.GetGuidFromXmlElement(oldNode);

            //create the node itself
            XmlElement dsRevitNode = MigrationManager.CreateFunctionNodeFrom(oldNode);

            MigrationManager.SetFunctionSignature(dsRevitNode, "RevitNodes.dll",
                                                  "Wall.ByCurveAndHeight",
                                                  "Wall.ByCurveAndHeight@Curve,double,Level,WallType");

            migratedData.AppendNode(dsRevitNode);
            string dsRevitNodeId = MigrationManager.GetGuidFromXmlElement(dsRevitNode);

            //create and reconnect the connecters
            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     oldInPort2 = new PortId(oldNodeId, 2, PortType.Input);
            XmlElement connector2 = data.FindFirstConnector(oldInPort2);

            PortId     oldInPort3 = new PortId(oldNodeId, 3, PortType.Input);
            XmlElement connector3 = data.FindFirstConnector(oldInPort3);

            PortId newInPort0 = new PortId(dsRevitNodeId, 0, PortType.Input);
            PortId newInPort1 = new PortId(dsRevitNodeId, 1, PortType.Input);
            PortId newInPort2 = new PortId(dsRevitNodeId, 2, PortType.Input);
            PortId newInPort3 = new PortId(dsRevitNodeId, 3, PortType.Input);

            data.ReconnectToPort(connector0, newInPort0);
            data.ReconnectToPort(connector1, newInPort2);
            data.ReconnectToPort(connector2, newInPort3);
            data.ReconnectToPort(connector3, newInPort1);

            return(migratedData);
        }
Exemple #17
0
        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            NodeMigrationData migrationData = new NodeMigrationData(data.Document);
            XmlElement        oldNode       = data.MigratedNodes.ElementAt(0);

            var newNode = MigrationManager.CreateFunctionNodeFrom(oldNode);

            MigrationManager.SetFunctionSignature(newNode, "DSOffice.dll",
                                                  "Excel.WriteDataToExcelWorksheet",
                                                  "Excel.WriteDataToExcelWorksheet@var,int,int,var[][]");

            migrationData.AppendNode(newNode);

            // Add default values
            foreach (XmlNode child in oldNode.ChildNodes)
            {
                newNode.AppendChild(child.Clone());
            }

            return(migrationData);
        }
Exemple #18
0
        public static NodeMigrationData Migrate_0700_to_0730(NodeMigrationData data)
        {
            var migrationData = new NodeMigrationData(data.Document);
            var oldNode       = data.MigratedNodes.ElementAt(0);

            var sunSettingNode = MigrationManager.CloneAndChangeName(
                oldNode,
                "DSRevitNodesUI.SunSettings",
                "SunSettings.Current");
            var sunSettingsNodeId = Guid.NewGuid().ToString();

            sunSettingNode.SetAttribute("guid", sunSettingsNodeId);
            migrationData.AppendNode(sunSettingNode);

            var sunPathNode = MigrationManager.CreateFunctionNodeFrom(oldNode);

            MigrationManager.SetFunctionSignature(
                sunPathNode,
                "RevitNodes.dll",
                "SunSettings.SunDirection",
                "SunSettings.SunDirection@var");
            migrationData.AppendNode(sunPathNode);

            migrationData.CreateConnector(sunSettingNode, 0, sunPathNode, 0);

            var oldConnector = data.FindFirstConnector(
                new PortId(MigrationManager.GetGuidFromXmlElement(oldNode), 0, PortType.Output));

            if (oldConnector != null)
            {
                migrationData.ReconnectToPort(
                    oldConnector,
                    new PortId(
                        MigrationManager.GetGuidFromXmlElement(sunPathNode),
                        0,
                        PortType.Output));
            }

            return(migrationData);
        }
Exemple #19
0
        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            NodeMigrationData migratedData = new NodeMigrationData(data.Document);
            XmlElement        oldNode      = data.MigratedNodes.ElementAt(0);
            string            oldNodeId    = MigrationManager.GetGuidFromXmlElement(oldNode);

            //create the node itself
            XmlElement dsRevitNode = MigrationManager.CreateFunctionNodeFrom(oldNode);

            MigrationManager.SetFunctionSignature(dsRevitNode, "RevitNodes.dll",
                                                  "FamilyInstance.ByPointAndLevel",
                                                  "FamilyInstance.ByPointAndLevel@FamilySymbol,Point,Level");

            migratedData.AppendNode(dsRevitNode);
            string dsRevitNodeId = MigrationManager.GetGuidFromXmlElement(dsRevitNode);

            //create and reconnect the connecters
            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     oldInPort2 = new PortId(oldNodeId, 2, PortType.INPUT);
            XmlElement connector2 = data.FindFirstConnector(oldInPort2);

            PortId newInPort0 = new PortId(dsRevitNodeId, 0, PortType.INPUT);
            PortId newInPort1 = new PortId(dsRevitNodeId, 1, PortType.INPUT);
            PortId newInPort2 = new PortId(dsRevitNodeId, 2, PortType.INPUT);

            data.ReconnectToPort(connector0, newInPort1);
            data.ReconnectToPort(connector1, newInPort0);
            data.ReconnectToPort(connector2, newInPort2);

            return(migratedData);
        }
Exemple #20
0
        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            NodeMigrationData migrationData = new NodeMigrationData(data.Document);

            // Create DSFunction nodes
            XmlElement oldNode = data.MigratedNodes.ElementAt(0);
            var        newNode = MigrationManager.CreateFunctionNodeFrom(oldNode);

            MigrationManager.SetFunctionSignature(newNode, "ProtoGeometry.dll",
                                                  "CoordinateSystem.ZXPlane", "CoordinateSystem.ZXPlane");
            migrationData.AppendNode(newNode);
            string newNodeId = MigrationManager.GetGuidFromXmlElement(newNode);

            var csNode = MigrationManager.CreateFunctionNode(data.Document, oldNode, 0, "ProtoGeometry.dll",
                                                             "CoordinateSystem.Identity", "CoordinateSystem.Identity");

            migrationData.AppendNode(csNode);
            string csNodeId = MigrationManager.GetGuidFromXmlElement(csNode);

            // Create connector
            data.CreateConnector(csNode, 0, newNode, 0);

            return(migrationData);
        }
Exemple #21
0
        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            var migrationData = new NodeMigrationData(data.Document);
            XmlElement oldNode = data.MigratedNodes.ElementAt(0);

            // Create nodes

            XmlElement sunPathNode = MigrationManager.CloneAndChangeName(
                oldNode, "DSRevitNodesUI.SunPathDirection", "SunPath Direction");
            sunPathNode.SetAttribute("guid", Guid.NewGuid().ToString());
            sunPathNode.SetAttribute("x", (Convert.ToDouble(oldNode.GetAttribute("x")) - 230).ToString());

            var vectorAsPoint = MigrationManager.CreateFunctionNodeFrom(oldNode);
            MigrationManager.SetFunctionSignature(vectorAsPoint, "ProtoGeometry.dll",
                "Vector.AsPoint", "Vector.AsPoint");
            
            migrationData.AppendNode(sunPathNode);
            migrationData.AppendNode(vectorAsPoint);

            // Update connectors
            migrationData.CreateConnector(sunPathNode, 0, vectorAsPoint, 0);

            return migrationData;
        }
Exemple #22
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",
                                                  "Curve.CoordinateSystemAtParameter", "Curve.CoordinateSystemAtParameter@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);
            XmlElement connector0 = data.FindFirstConnector(oldInPort0);
            XmlElement connector1 = data.FindFirstConnector(oldInPort1);

            data.ReconnectToPort(connector0, oldInPort1);
            data.ReconnectToPort(connector1, oldInPort0);

            return(migrationData);
        }
Exemple #23
0
        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            NodeMigrationData migratedData = new NodeMigrationData(data.Document);
            XmlElement        oldNode      = data.MigratedNodes.ElementAt(0);
            string            oldNodeId    = MigrationManager.GetGuidFromXmlElement(oldNode);

            XmlElement dsRevitNode = MigrationManager.CreateFunctionNodeFrom(oldNode);

            MigrationManager.SetFunctionSignature(dsRevitNode, "ProtoGeometry.dll",
                                                  "Solid.ByLoft", "Solid.ByLoft@Curve[]");
            migratedData.AppendNode(dsRevitNode);
            string dsRevitNodeId = MigrationManager.GetGuidFromXmlElement(dsRevitNode);

            XmlElement createListNode = MigrationManager.CreateNode(data.Document,
                                                                    oldNode, 0, "DSCoreNodesUI.CreateList", "Create List");

            migratedData.AppendNode(createListNode);
            createListNode.SetAttribute("inputcount", "2");
            string createListNodeId = MigrationManager.GetGuidFromXmlElement(createListNode);

            //create and reconnect the connecters
            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(createListNodeId, 0, PortType.INPUT);
            PortId newInPort1 = new PortId(createListNodeId, 1, PortType.INPUT);

            data.ReconnectToPort(connector0, newInPort0);
            data.ReconnectToPort(connector1, newInPort1);
            data.CreateConnector(createListNode, 0, dsRevitNode, 0);

            return(migratedData);
        }
Exemple #24
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);
        }
Exemple #25
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",
                "EllipseArc.ByPlaneRadiiStartAngleSweepAngle", 
                "EllipseArc.ByPlaneRadiiStartAngleSweepAngle@Plane,double,double,double,double");
            migrationData.AppendNode(newNode);
            string newNodeId = MigrationManager.GetGuidFromXmlElement(newNode);

            // Create new node
            XmlElement zAxis = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 0, "ProtoGeometry.dll",
                "Vector.ZAxis",
                "Vector.ZAxis");
            migrationData.AppendNode(zAxis);

            XmlElement planeNode = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 1, "", "Plane.ByOriginNormal", 
                "Plane.ByOriginNormal@Point,Vector");
            planeNode.SetAttribute("isVisible", "false");
            migrationData.AppendNode(planeNode);
            string planeNodeId = MigrationManager.GetGuidFromXmlElement(planeNode);

            XmlElement converterNode0 = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 2, "DSCoreNodes.dll",
                "Math.RadiansToDegrees", "Math.RadiansToDegrees@double");
            migrationData.AppendNode(converterNode0);
            string converterNode0Id = MigrationManager.GetGuidFromXmlElement(converterNode0);

            XmlElement converterNode1 = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 3, "DSCoreNodes.dll",
                "Math.RadiansToDegrees", "Math.RadiansToDegrees@double");
            migrationData.AppendNode(converterNode1);
            string converterNode1Id = MigrationManager.GetGuidFromXmlElement(converterNode1);

            XmlElement minusNode = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 4, "", "-", "-@,");
            migrationData.AppendNode(minusNode);
            string minusNodeId = MigrationManager.GetGuidFromXmlElement(minusNode);

            // Update connectors
            PortId oldInPort0 = new PortId(newNodeId, 0, PortType.Input);
            PortId oldInPort3 = new PortId(newNodeId, 3, PortType.Input);
            PortId oldInPort4 = new PortId(newNodeId, 4, PortType.Input);

            PortId planeNodeInPort = new PortId(planeNodeId, 0, PortType.Input);
            PortId converterInPort = new PortId(converterNode0Id, 0, PortType.Input);
            PortId minusNodeInPort0 = new PortId(minusNodeId, 0, PortType.Input);
            PortId minusNodeInPort1 = new PortId(minusNodeId, 1, PortType.Input);

            XmlElement connector0 = data.FindFirstConnector(oldInPort0);
            XmlElement connector3 = data.FindFirstConnector(oldInPort3);
            XmlElement connector4 = data.FindFirstConnector(oldInPort4);

            data.ReconnectToPort(connector0, planeNodeInPort);
            data.ReconnectToPort(connector3, converterInPort);
            data.ReconnectToPort(connector4, minusNodeInPort0);

            if (connector3 != null)
            {
                XmlElement connector5 = MigrationManager.CreateFunctionNodeFrom(connector3);
                data.CreateConnector(connector5);
                data.ReconnectToPort(connector5, minusNodeInPort1);
            }

            data.CreateConnector(minusNode, 0, converterNode1, 0);
            data.CreateConnector(converterNode0, 0, newNode, 3);
            data.CreateConnector(converterNode1, 0, newNode, 4);
            data.CreateConnector(zAxis, 0, planeNode, 1);
            data.CreateConnector(planeNode, 0, newNode, 0);

            return migrationData;
        }
Exemple #26
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);
        }
Exemple #27
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 referencePoint = MigrationManager.CreateFunctionNodeFrom(oldNode);

            MigrationManager.SetFunctionSignature(referencePoint,
                                                  "RevitNodes.dll", "ReferencePoint.ByPoint",
                                                  "ReferencePoint.ByPoint@Point");
            migrationData.AppendNode(referencePoint);
            string referencePointId = MigrationManager.GetGuidFromXmlElement(referencePoint);

            XmlElement pointAtParameter = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 0, "RevitNodes.dll",
                "Face.PointAtParameter", "Face.PointAtParameter@double,double");

            migrationData.AppendNode(pointAtParameter);
            string pointAtParameterId = MigrationManager.GetGuidFromXmlElement(pointAtParameter);

            XmlElement uvU = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 1, "ProtoGeometry.dll", "UV.U", "UV.U");

            migrationData.AppendNode(uvU);
            string uvUId = MigrationManager.GetGuidFromXmlElement(uvU);

            XmlElement uvV = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 2, "ProtoGeometry.dll", "UV.V", "UV.V");

            migrationData.AppendNode(uvV);
            string uvVId = MigrationManager.GetGuidFromXmlElement(uvV);

            // Update connectors
            PortId     oldInPort0  = new PortId(oldNodeId, 0, PortType.INPUT);
            PortId     oldInPort1  = new PortId(oldNodeId, 1, PortType.INPUT);
            PortId     papInPort0  = new PortId(pointAtParameterId, 0, PortType.INPUT);
            PortId     uvUInPort0  = new PortId(uvUId, 0, PortType.INPUT);
            XmlElement connector0  = data.FindFirstConnector(oldInPort0);
            XmlElement connector1  = data.FindFirstConnector(oldInPort1);
            XmlElement connectorUv = null;

            if (connector1 != null)
            {
                connectorUv = MigrationManager.CreateFunctionNodeFrom(connector1);
                data.CreateConnector(connectorUv);
            }

            if (connectorUv != null)
            {
                PortId uvVInPort0 = new PortId(uvVId, 0, PortType.INPUT);
                data.ReconnectToPort(connectorUv, uvVInPort0);
            }

            data.ReconnectToPort(connector0, papInPort0);
            data.ReconnectToPort(connector1, uvUInPort0);
            data.CreateConnector(uvU, 0, pointAtParameter, 1);
            data.CreateConnector(uvV, 0, pointAtParameter, 2);
            data.CreateConnector(pointAtParameter, 0, referencePoint, 0);

            return(migrationData);
        }
Exemple #28
0
        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            #region Migration Setup Steps

            NodeMigrationData migratedData = new NodeMigrationData(data.Document);

            // Legacy "ModelText" node takes in the following 6 inputs:
            //
            //      0 - text (string)
            //      1 - position (XYZ)
            //      2 - normal (XYZ)
            //      3 - up (XYZ)
            //      4 - depth (double)
            //      5 - text type name (string)
            //
            // The new "ModelText.ByTextSketchPlaneAndPosition" node takes in
            // the following inputs:
            //
            //      0 - text (string)
            //      1 - sketchPlane (SketchPlane)
            //      2 - xCoordinateInPlane (double)
            //      3 - yCoordinateInPlane (double)
            //      4 - textDepth (double)
            //      5 - modelTextType (ModelTextType)
            //
            XmlElement oldNode   = data.MigratedNodes.ElementAt(0);
            string     oldNodeId = MigrationManager.GetGuidFromXmlElement(oldNode);

            #endregion

            #region Create New Nodes...

            XmlElement dsModelText = MigrationManager.CreateFunctionNodeFrom(oldNode);
            MigrationManager.SetFunctionSignature(dsModelText, "RevitNodes.dll",
                                                  "ModelText.ByTextSketchPlaneAndPosition",
                                                  "ModelText.ByTextSketchPlaneAndPosition@" +
                                                  "string,SketchPlane,double,double,double,ModelTextType");

            migratedData.AppendNode(dsModelText);
            string dsModelTextId = MigrationManager.GetGuidFromXmlElement(dsModelText);

            // Create a "Plane.ByOriginNormal" that takes a "Point" (origin) and
            // a "Vector" (normal). This new node will convert both the "position"
            // and "normal" to a "Plane".
            XmlElement plane = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 0, "ProtoGeometry.dll", "Plane.ByOriginNormal",
                "Plane.ByOriginNormal@Point,Vector");

            migratedData.AppendNode(plane);
            string planeId = MigrationManager.GetGuidFromXmlElement(plane);

            // Create a "SketchPlane.ByPlane" node which converts a "Plane"
            // into a "SketchPlane".
            XmlElement dsSketchPlane = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 1, "RevitNodes.dll",
                "SketchPlane.ByPlane", "SketchPlane.ByPlane@Plane");

            migratedData.AppendNode(dsSketchPlane);
            string dsSketchPlaneId = MigrationManager.GetGuidFromXmlElement(dsSketchPlane);

            // Create a "ModelTextType.ByName" node that converts a "string"
            // into "ModelTextType" node.
            XmlElement dsModelTextType = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 2, "RevitNodes.dll",
                "ModelTextType.ByName", "ModelTextType.ByName@string");

            migratedData.AppendNode(dsModelTextType);
            string dsModelTextTypeId = MigrationManager.GetGuidFromXmlElement(dsModelTextType);

            //append asVector Node
            XmlElement pointAsVector0 = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 3, "ProtoGeometry.dll",
                "Point.AsVector", "Point.AsVector");
            migratedData.AppendNode(pointAsVector0);
            string pointAsVector0Id = MigrationManager.GetGuidFromXmlElement(pointAsVector0);

            //append number Node
            XmlElement numberNode = MigrationManager.CreateCodeBlockNodeModelNode(
                data.Document, oldNode, 4, "0;");
            migratedData.AppendNode(numberNode);

            #endregion

            #region Move Connectors Onto the New Nodes

            // Move connector for "text" over to the new node.
            PortId     oldInPort = new PortId(oldNodeId, 0, PortType.Input);
            PortId     newInPort = new PortId(dsModelTextId, 0, PortType.Input);
            XmlElement connector = data.FindFirstConnector(oldInPort);
            data.ReconnectToPort(connector, newInPort);

            // Move connector for "position" over to "Plane" node.
            oldInPort = new PortId(oldNodeId, 1, PortType.Input);
            newInPort = new PortId(planeId, 0, PortType.Input);
            connector = data.FindFirstConnector(oldInPort);
            data.ReconnectToPort(connector, newInPort);

            // Move connector for "normal" over to "Plane" node.
            oldInPort = new PortId(oldNodeId, 2, PortType.Input);
            newInPort = new PortId(pointAsVector0Id, 0, PortType.Input);
            connector = data.FindFirstConnector(oldInPort);
            data.ReconnectToPort(connector, newInPort);
            data.CreateConnector(pointAsVector0, 0, plane, 1);

            // Connect from "Plane" to "SketchPlane".
            data.CreateConnector(plane, 0, dsSketchPlane, 0);

            // Connect from "SketchPlane" to the new node.
            data.CreateConnector(dsSketchPlane, 0, dsModelText, 1);

            oldInPort = new PortId(oldNodeId, 3, PortType.Input);
            data.RemoveFirstConnector(oldInPort);

            // Move connector for "depth" over to the new node.
            oldInPort = new PortId(oldNodeId, 4, PortType.Input);
            newInPort = new PortId(dsModelTextId, 4, PortType.Input);
            connector = data.FindFirstConnector(oldInPort);
            data.ReconnectToPort(connector, newInPort);

            // Move connector for "text type name" over to "ModelTextType" node.
            oldInPort = new PortId(oldNodeId, 5, PortType.Input);
            newInPort = new PortId(dsModelTextTypeId, 0, PortType.Input);
            connector = data.FindFirstConnector(oldInPort);
            data.ReconnectToPort(connector, newInPort);

            // Connect from "ModelTextType" to the new node.
            data.CreateConnector(dsModelTextType, 0, dsModelText, 5);

            data.CreateConnector(numberNode, 0, dsModelText, 2);
            data.CreateConnector(numberNode, 0, dsModelText, 3);

            #endregion

            return(migratedData);
        }
Exemple #29
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);
        }
Exemple #30
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);
        }