Пример #1
0
        public void ByFace_UpdateLocation_ProducesValidFamilyInstanceWithCorrectLocation()
        {
            string samplePath = Path.Combine(workingDirectory, @".\ElementBinding\FamilyInstancePlacementByFace.dyn");
            string testPath   = Path.GetFullPath(samplePath);

            ViewModel.OpenCommand.Execute(testPath);

            var initialNumber = TestUtils.GetAllFamilyInstances().Count;

            // The current Revit file already has a family placed at UV param location 0.50
            // We update placement location of family instance to 0.75 param location
            var cbn = GetNode <CodeBlockNodeModel>("a7e21de3-bff4-4d1d-b23d-3fb2db980d57");

            var command = new Dynamo.Models.DynamoModel.UpdateModelValueCommand(
                Guid.Empty, cbn.GUID, "Code", "0.75");

            this.Model.ExecuteCommand(command);

            RunCurrentModel();

            var finalNumber = TestUtils.GetAllFamilyInstances().Count;
            var famInst     = GetPreviewValue("56cf69ec-d4ca-4add-810d-aee64d003c76") as Revit.Elements.FamilyInstance;

            Assert.IsNotNull(famInst);

            // Assert that there is no change in the total number of family instances in the document
            // as the original should have been updated and no new one should be created
            Assert.AreEqual(initialNumber, finalNumber);
        }
Пример #2
0
        public void Level()
        {
            var samplePath = Path.Combine(workingDirectory, @".\Level\Level.dyn");
            var testPath   = Path.GetFullPath(samplePath);

            ViewModel.OpenCommand.Execute(testPath);

            AssertNoDummyNodes();

            RunCurrentModel();

            //ensure that the level count is the same
            var levelColl = new FilteredElementCollector(DocumentManager.Instance.CurrentUIDocument.Document);

            levelColl.OfClass(typeof(Level));
            Assert.AreEqual(levelColl.ToElements().Count(), 6);

            //change the number and run again
            var cbnNode = ViewModel.Model.CurrentWorkspace.FirstNodeFromWorkspace <CodeBlockNodeModel>();
            var cmd     = new Dynamo.Models.DynamoModel.UpdateModelValueCommand(Guid.Empty, cbnNode.GUID, "Code", "0..20..2");

            Model.ExecuteCommand(cmd);

            RunCurrentModel();

            //ensure that the level count is the same
            levelColl = new FilteredElementCollector(DocumentManager.Instance.CurrentUIDocument.Document);
            levelColl.OfClass(typeof(Level));
            Assert.AreEqual(levelColl.ToElements().Count(), 11);
        }
Пример #3
0
        public void ByFace_UpdateLocation_ProducesValidFamilyInstanceWithCorrectLocation()
        {
            string samplePath = Path.Combine(workingDirectory, @".\Family\FamilyInstancePlacementByFace.dyn");
            string testPath   = Path.GetFullPath(samplePath);

            ViewModel.OpenCommand.Execute(testPath);
            RunCurrentModel();

            var initialNumber = GetAllFamilyInstances(false).Count;
            var famInst1      = GetPreviewValue("e8dbd9fa-c0fd-4a5c-9cd8-2616f98285c8") as FamilyInstance;

            Assert.IsNotNull(famInst1);

            // Update placement location of family instance
            var cbn = GetNode <CodeBlockNodeModel>("31b09d10-931b-4ac1-b2cc-7e04faf334dc");

            var command = new Dynamo.Models.DynamoModel.UpdateModelValueCommand(
                Guid.Empty, cbn.GUID, "Code", "0.75");

            this.Model.ExecuteCommand(command);

            RunCurrentModel();

            var finalNumber = GetAllFamilyInstances(false).Count;
            var famInst2    = GetPreviewValue("e8dbd9fa-c0fd-4a5c-9cd8-2616f98285c8") as FamilyInstance;

            Assert.IsNotNull(famInst2);

            // PointAtParameter on surface
            var pnt = GetPreviewValue("31171a34-edd6-4c81-b821-2ad0bae36aab") as Autodesk.DesignScript.Geometry.Point;

            Assert.IsNotNull(pnt);

            var pos = famInst2.Location;

            // Verify that location of family instance matches with the placement point on surface
            Assert.AreEqual(pnt.X, pos.X, Epsilon, "X property does not match");
            Assert.AreEqual(pnt.Y, pos.Y, Epsilon, "Y property does not match");
            Assert.AreEqual(pnt.Z, pos.Z, Epsilon, "Z property does not match");

            // Element ID of Revit face selected in DYN file
            var elId            = new Autodesk.Revit.DB.ElementId(250730);
            var internalFamInst = famInst2.InternalElement as Autodesk.Revit.DB.FamilyInstance;

            Assert.IsNotNull(internalFamInst);

            // Verify that the Revit face selected is the hosting face of the family instance
            Assert.AreEqual(elId, internalFamInst.HostFace.ElementId);

            // Assert that there is no change in the total number of family instances in the document
            // as the original should have been updated and no new one should be created
            Assert.AreEqual(initialNumber, finalNumber);
        }
Пример #4
0
        public void MultipleCustomNodeInstance()
        {
            string dynPath = Path.Combine(workingDirectory, @".\ElementBinding\PlaceMultipleRevitCustomNodes.dyn");

            ViewModel.OpenCommand.Execute(dynPath);
            RunCurrentModel();

            var walls = GetAllWalls();

            Assert.AreEqual(8, walls.Count());

            var cbn     = GetNode <CodeBlockNodeModel>("a4705f1f-1cfb-43eb-ba35-a797d5703d37");
            var command = new Dynamo.Models.DynamoModel.UpdateModelValueCommand(Guid.Empty, cbn.GUID, "Code", "100;100;");

            this.Model.ExecuteCommand(command);

            walls = GetAllWalls();
            Assert.AreEqual(8, walls.Count());
        }