Example #1
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 newNode = MigrationManager.CreateFunctionNodeFrom(oldNode);
            MigrationManager.SetFunctionSignature(newNode, "ProtoGeometry.dll",
                "Surface.ByLoft",
                "[email protected][]");

            migratedData.AppendNode(newNode);
            string newNodeId = MigrationManager.GetGuidFromXmlElement(newNode);


            PortId oldInPort0 = new PortId(oldNodeId, 0, PortType.INPUT);
            data.RemoveFirstConnector(oldInPort0);

            PortId oldInPort1 = new PortId(oldNodeId, 1, PortType.INPUT);
            XmlElement connector1 = data.FindFirstConnector(oldInPort1);
            PortId newInPort0 = new PortId(newNodeId, 0, PortType.INPUT);
            data.ReconnectToPort(connector1, newInPort0);

            PortId oldInPort2 = new PortId(oldNodeId, 2, PortType.INPUT);
            data.RemoveFirstConnector(oldInPort2);

            return migratedData;
        }
Example #2
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",
                "Autodesk.DesignScript.Geometry.Solid.BySweep",
                "Autodesk.DesignScript.Geometry.Solid.BySweep@" + 
                "Autodesk.DesignScript.Geometry.Curve,Autodesk.DesignScript.Geometry.Curve");
            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 oldInPort3 = new PortId(newNodeId, 3, PortType.INPUT);

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

            XmlElement connector0 = data.FindFirstConnector(oldInPort0);
            XmlElement connector3 = data.FindFirstConnector(oldInPort3);
            data.RemoveFirstConnector(oldInPort1);

            //connector1.RemoveAll();
            data.ReconnectToPort(connector0, newInPort1);
            data.ReconnectToPort(connector3, newInPort0);

            return migrationData;
        }
Example #3
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",
                "FaceAnalysisDisplay.ByViewFacePointsAndValues",
                "FaceAnalysisDisplay.ByViewFacePointsAndValues@var,FaceReference,double[][],double[]");

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

            XmlElement documentNode = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 0, "RevitNodes.dll",
                "Document.Current", "Document.Current");
            migratedData.AppendNode(documentNode);

            XmlElement activeViewNode = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 1, "RevitNodes.dll",
                "Document.ActiveView", "Document.ActiveView");
            migratedData.AppendNode(activeViewNode);

            //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);
            
            PortId oldInPort3 = new PortId(oldNodeId, 3, PortType.Input);
            XmlElement connector3 = data.FindFirstConnector(oldInPort3);

            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, newInPort3);
            data.ReconnectToPort(connector1, newInPort2);
            data.ReconnectToPort(connector3, newInPort1);

            data.RemoveFirstConnector(oldInPort2);
            data.CreateConnector(documentNode, 0, activeViewNode, 0);
            data.CreateConnector(activeViewNode, 0, dsRevitNode, 0);

            return migratedData;
        }
Example #4
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;
        }