コード例 #1
0
        private void ChangeNumberValueAndCheckElementCount(DoubleInput numNode, Document doc, int value, int power)
        {
            numNode.Value = value.ToString();
            RunCurrentModel();
            var refPts = Utils.AllElementsOfType <ReferencePoint>(doc);

            Assert.AreEqual(refPts.Count(), Math.Pow(value + 1, power));
        }
コード例 #2
0
        public void Rebinding_ReboundAdaptiveComponentsAreNotDeleted()
        {
            var model = OpenElementBindingWorkspace("RebindingBatchedACs.dyn");

            RunCurrentModel();
            NodeModel adaptiveCompNode = model.CurrentWorkspace.Nodes.Where(x => x.Name == "AdaptiveComponent.ByPoints").First();

            var doc             = DocumentManager.Instance.CurrentDBDocument;
            var familyInstances = Utils.AllElementsOfType <FamilyInstance>(doc);

            Assert.AreEqual(9, adaptiveCompNode.GetValue(0, model.EngineController).GetElements().Select(x => x.Data).ToList().Count);
        }
コード例 #3
0
        public void Rebinding_NodeDeletedBeforeRun()
        {
            var model = OpenElementBindingWorkspace("RebindingSingleDimension.dyn");

            var refPtNode = model.CurrentWorkspace.FirstNodeFromWorkspace <DSFunction>();
            var command   = new DynamoModel.DeleteModelCommand(refPtNode.GUID);

            ViewModel.ExecuteCommand(command);
            RunCurrentModel();

            var doc    = DocumentManager.Instance.CurrentDBDocument;
            var refPts = Utils.AllElementsOfType <ReferencePoint>(doc);

            Assert.AreEqual(refPts.Count(), 0);
        }
コード例 #4
0
        public void VerifyJsonRestoresExpectedBinding()
        {
            // Test variables
            int       wallElementCountPresave;
            int       wallElementCountPostsave;
            ElementId wallElementIdPresave;
            ElementId wallElementIdPostsave;

            // Load Dynamo xml file containing trace data
            string dynFilePath = Path.Combine(workingDirectory, @".\ElementBinding\CreateWallInDynamo.dyn");
            string testPath    = Path.GetFullPath(dynFilePath);

            ViewModel.OpenCommand.Execute(testPath);

            // Run
            RunCurrentModel();

            // Get binding element id for wall node presave
            var selNodes = ViewModel.Model.CurrentWorkspace.Nodes.Where(x => string.Equals(x.GUID.ToString(), "b568d298-f7be-4619-99a1-cae16efaed58"));

            Assert.IsTrue(selNodes.Any());
            var node = selNodes.First();

            wallElementIdPresave = GetBindingElementIdForNode(node.GUID);

            // Get initial wall count
            var doc = DocumentManager.Instance.CurrentUIDocument.Document;
            IEnumerable <Element> wallsPresave = Utils.AllElementsOfType <Wall>(doc);

            wallElementCountPresave = wallsPresave.Count();

            // Save in temp location
            string tempPath = Path.Combine(workingDirectory, @".\ElementBinding\CreateWallInDynamo_temp.dyn");

            ViewModel.SaveAsCommand.Execute(tempPath);

            // Close workspace
            Assert.IsTrue(ViewModel.CloseHomeWorkspaceCommand.CanExecute(null));
            ViewModel.CloseHomeWorkspaceCommand.Execute(null);

            // Open Json temp file
            dynFilePath = Path.Combine(workingDirectory, @".\ElementBinding\CreateWallInDynamo_temp.dyn");
            testPath    = Path.GetFullPath(dynFilePath);
            ViewModel.OpenCommand.Execute(testPath);

            // Run
            RunCurrentModel();

            // Get binding element id for wall node postsave
            selNodes = ViewModel.Model.CurrentWorkspace.Nodes.Where(x => string.Equals(x.GUID.ToString(), "b568d298-f7be-4619-99a1-cae16efaed58"));
            Assert.IsTrue(selNodes.Any());
            node = selNodes.First();
            wallElementIdPostsave = GetBindingElementIdForNode(node.GUID);

            // Get wall count upon reopening to verify no duplicate walls exist
            doc = DocumentManager.Instance.CurrentUIDocument.Document;
            IEnumerable <Element> wallsPostsave = Utils.AllElementsOfType <Wall>(doc);

            wallElementCountPostsave = wallsPostsave.Count();

            // Verify xml results against json
            Assert.AreEqual(wallElementIdPresave, wallElementIdPostsave);
            Assert.AreEqual(wallElementCountPresave, wallElementCountPostsave);

            // Delete temp file
            File.Delete(tempPath);
        }