Exemple #1
0
        public void TestCreateNode()
        {
            //Arrange
            string documentDynPath = Path.Combine(TestDirectory, @"core\NodeStates.dyn");
            XmlDocument xmlDoc = new XmlDocument();
            XmlDocument xmlOldNodeDoc = new XmlDocument();
            xmlOldNodeDoc.LoadXml("<Dynamo.Graph.Nodes.CodeBlockNodeModel type=\"Dynamo.Graph.Nodes.CodeBlockNodeModel\"  x=\"203.6\" y=\"220\"/>");
            XmlElement xmlOldNode = xmlOldNodeDoc.DocumentElement;
            XmlElement xmlResult = null;

            //Act
            if (File.Exists(documentDynPath))
            {
                xmlDoc.Load(documentDynPath);
                xmlResult = MigrationManager.CreateNode(xmlDoc, xmlOldNode, 0, "Dynamo.Graph.Nodes.CodeBlockNodeModel", "CodeBlock1");
            }

            //Assert
            //Check that all the attibutes where generated correctly
            Assert.IsNotNull(xmlResult);
            Assert.AreEqual(xmlResult.GetAttribute("type"), "Dynamo.Graph.Nodes.CodeBlockNodeModel");
            Assert.AreEqual(xmlResult.GetAttribute("nickname"), "CodeBlock1");
        }
Exemple #2
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);
        }