예제 #1
0
        public void ByNameNumberTitleBlockAndViews_BadArgs()
        {
            ElementBinder.IsEnabled = false;

            var famSymName = "E1 30x42 Horizontal";
            var famName    = "E1 30 x 42 Horizontal";
            var titleBlock = FamilyType.ByFamilyAndName(Family.ByName(famName), famSymName);

            var famTyp  = FamilyType.ByName("Kousa Dogwood - 10'");
            var pt      = Point.ByCoordinates(0, 1, 2);
            var famInst = FamilyInstance.ByPoint(famTyp, pt);

            var pt2      = Point.ByCoordinates(100, 100, 0);
            var famInst2 = FamilyInstance.ByPoint(famTyp, pt2);

            var view  = SectionView.ByBoundingBox(famInst.BoundingBox);
            var view2 = SectionView.ByBoundingBox(famInst2.BoundingBox);

            var sheetName   = "Poodle";
            var sheetNumber = "A1";

            Assert.Throws(typeof(ArgumentNullException), () => Sheet.ByNameNumberTitleBlockAndViews(null, sheetNumber, titleBlock, new[] { view, view2 }));
            Assert.Throws(typeof(ArgumentNullException), () => Sheet.ByNameNumberTitleBlockAndViews(sheetName, null, titleBlock, new[] { view, view2 }));
            Assert.Throws(typeof(ArgumentNullException), () => Sheet.ByNameNumberTitleBlockAndViews(sheetName, sheetNumber, null, new[] { view, view2 }));
            Assert.Throws(typeof(ArgumentNullException), () => Sheet.ByNameNumberTitleBlockAndViews(sheetName, sheetNumber, titleBlock, null));
        }
예제 #2
0
        public void ByNameNumberTitleBlockViewsAndLocations_ValidArgs()
        {
            ElementBinder.IsEnabled = false;

            var famSymName = "E1 30x42 Horizontal";
            var famName    = "E1 30 x 42 Horizontal";
            var titleBlock = FamilyType.ByFamilyAndName(Family.ByName(famName), famSymName);

            var famTyp  = FamilyType.ByName("Kousa Dogwood - 10'");
            var pt      = Point.ByCoordinates(0, 1, 2);
            var famInst = FamilyInstance.ByPoint(famTyp, pt);

            var pt2      = Point.ByCoordinates(100, 100, 0);
            var famInst2 = FamilyInstance.ByPoint(famTyp, pt2);

            var view  = SectionView.ByBoundingBox(famInst.BoundingBox);
            var view2 = SectionView.ByBoundingBox(famInst2.BoundingBox);

            var location  = Point.ByCoordinates(0, 0, 0);
            var location2 = Point.ByCoordinates(0, 1, 0);

            var sheetName   = "Poodle";
            var sheetNumber = "A1";

            var ele = Sheet.ByNameNumberTitleBlockViewsAndLocations(sheetName, sheetNumber, titleBlock, new[] { view, view2 }, new[] { location, location2 });

            Assert.NotNull(ele);
        }
예제 #3
0
        public void ByName_GoodArgs()
        {
            var famTyp = FamilyType.ByName("Box");

            Assert.NotNull(famTyp);
            Assert.AreEqual("Box", famTyp.Name);
            Assert.AreEqual("Box", famTyp.Family.Name);
        }
예제 #4
0
        public void ByEyePointTargetAndElement_BadArgs()
        {
            var eye    = Point.ByCoordinates(100, 100, 100);
            var target = Point.ByCoordinates(0, 1, 2);
            var name   = "treeView";

            var famTyp  = FamilyType.ByName("Kousa Dogwood - 10'");
            var pt      = Point.ByCoordinates(0, 1, 2);
            var famInst = FamilyInstance.ByPoint(famTyp, pt);

            Assert.Throws(typeof(ArgumentNullException), () => AxonometricView.ByEyePointTargetAndElement(null, target, name, famInst, false));
            Assert.Throws(typeof(ArgumentNullException), () => AxonometricView.ByEyePointTargetAndElement(eye, null, name, famInst, false));
        }
예제 #5
0
        public void ByBoundingBox_ValidArgs()
        {
            var famTyp  = FamilyType.ByName("Kousa Dogwood - 10'");
            var pt      = Point.ByCoordinates(0, 1, 2);
            var famInst = FamilyInstance.ByPoint(famTyp, pt);

            var view = SectionView.ByBoundingBox(famInst.BoundingBox);

            Assert.NotNull(view);

            Assert.IsTrue(DocumentManager.Instance.ElementExistsInDocument(
                              new ElementUUID(view.InternalElement.UniqueId)));
        }
예제 #6
0
        public void ByEyePointTargetAndElement_DefaultArgs()
        {
            var eye    = Point.ByCoordinates(100, 100, 100);
            var target = Point.ByCoordinates(0, 1, 2);

            var famTyp  = FamilyType.ByName("Kousa Dogwood - 10'");
            var pt      = Point.ByCoordinates(0, 1, 2);
            var famInst = FamilyInstance.ByPoint(famTyp, pt);

            var v    = AxonometricView.ByEyePointTargetAndBoundingBox(eye, target, famInst.BoundingBox);
            var view = (Autodesk.Revit.DB.View3D)v.InternalElement;

            Assert.AreEqual(view.Name, AbstractView3D.DefaultViewName);
            Assert.False(view.CropBoxActive);
        }
예제 #7
0
        public void StructuralFraming_Brace_BadArgs()
        {
            var start  = Point.ByCoordinates(1, 2, 3);
            var end    = Point.ByCoordinates(5, 8, 3);
            var line   = Line.ByStartPointEndPoint(start, end);
            var level  = Level.ByElevation(3);
            var famTyp = FamilyType.ByName("W12X26");

            Assert.Throws <System.ArgumentNullException>(
                () => StructuralFraming.BraceByCurve(null, level, famTyp));
            Assert.Throws <System.ArgumentNullException>(
                () => StructuralFraming.BraceByCurve(line, null, famTyp));
            Assert.Throws <System.ArgumentNullException>(
                () => StructuralFraming.BraceByCurve(line, level, null));
        }
예제 #8
0
        public void StructuralFraming_Brace_ValidArgs()
        {
            var start  = Point.ByCoordinates(1, 2, 3);
            var end    = Point.ByCoordinates(5, 8, 3);
            var line   = Line.ByStartPointEndPoint(start, end);
            var level  = Level.ByElevation(3);
            var famTyp = FamilyType.ByName("W12X26");

            var structure = StructuralFraming.BraceByCurve(line, level, famTyp);

            Assert.NotNull(structure);
            Assert.NotNull(structure.InternalElement);
            Assert.IsTrue(DocumentManager.Instance.ElementExistsInDocument(
                              new ElementUUID(structure.InternalElement.UniqueId)));
        }
예제 #9
0
        public void ByEyePointTargetAndBoundingBox_ValidArgs()
        {
            var eye    = Point.ByCoordinates(100, 100, 100);
            var target = Point.ByCoordinates(0, 1, 2);
            var name   = "treeView";

            var famTyp  = FamilyType.ByName("Kousa Dogwood - 10'");
            var pt      = Point.ByCoordinates(0, 1, 2);
            var famInst = FamilyInstance.ByPoint(famTyp, pt);

            var view = AxonometricView.ByEyePointTargetAndBoundingBox(eye, target, famInst.BoundingBox, name, false);

            Assert.NotNull(view);
            Assert.IsTrue(DocumentManager.Instance.ElementExistsInDocument(
                              new ElementUUID(view.InternalElement.UniqueId)));
        }
예제 #10
0
        public void ByCurveLevelUpVectorAndType_BadArgs()
        {
            var start = Point.ByCoordinates(1, 2, 3);
            var end   = Point.ByCoordinates(5, 8, 3);
            var line  = Line.ByStartPointEndPoint(start, end);

            var level = Level.ByElevation(3);
            var up    = Vector.ByCoordinates(0, 0, 1);

            var structuralType = StructuralType.Beam;
            var famTyp         = FamilyType.ByName("W12X26");

            Assert.Throws(typeof(System.ArgumentNullException), () => StructuralFraming.ByCurveLevelUpVectorAndType(null, level, up, structuralType, famTyp));
            Assert.Throws(typeof(System.ArgumentNullException), () => StructuralFraming.ByCurveLevelUpVectorAndType(line, null, up, structuralType, famTyp));
            Assert.Throws(typeof(System.ArgumentNullException), () => StructuralFraming.ByCurveLevelUpVectorAndType(line, level, null, structuralType, famTyp));
            Assert.Throws(typeof(System.ArgumentNullException), () => StructuralFraming.ByCurveLevelUpVectorAndType(line, level, up, structuralType, null));
        }
예제 #11
0
        public void ByEyePointAndTarget_ValidAbstractElement()
        {
            var eye    = Point.ByCoordinates(100, 100, 100);
            var target = Point.ByCoordinates(0, 1, 2);
            var name   = "treeView";

            var famTyp  = FamilyType.ByName("Kousa Dogwood - 10'");
            var pt      = Point.ByCoordinates(0, 1, 2);
            var famInst = FamilyInstance.ByPoint(famTyp, pt);

            object element = famInst;
            var    view    = PerspectiveView.ByEyePointAndTarget(eye, target, element, name, false);

            Assert.NotNull(view);
            Assert.IsTrue(DocumentManager.Instance.ElementExistsInDocument(
                              new ElementUUID(view.InternalElement.UniqueId)));
        }
예제 #12
0
        public void CanConvertProtoToRevitType()
        {
            var famTyp  = FamilyType.ByName("Box");
            var pt      = Point.ByCoordinates(0, 1, 2);
            var famInst = FamilyInstance.ByPoint(famTyp, pt);

            var bbox = famInst.BoundingBox;

            var bbxyz = bbox.ToRevitType();

            var max = bbxyz.Max;
            var min = bbxyz.Min;

            // the box is 30ft x 30ft x 30ft
            // the placement point is the center of the bottom face of the box
            var boxOffsetTop    = Vector.ByCoordinates(15, 15, 30);
            var boxOffsetBottom = Vector.ByCoordinates(-15, -15, 0);

            min.ShouldBeApproximately((Point)pt.InHostUnits().Translate(boxOffsetBottom));
            max.ShouldBeApproximately((Point)pt.InHostUnits().Translate(boxOffsetTop));
        }
예제 #13
0
        public void CanConvertRevitToProtoType()
        {
            var famTyp  = FamilyType.ByName("Box");
            var pt      = Point.ByCoordinates(0, 1, 2);
            var famInst = FamilyInstance.ByPoint(famTyp, pt);

            var bbox = famInst.BoundingBox;

            Assert.NotNull(bbox);

            var max = bbox.MaxPoint;
            var min = bbox.MinPoint;

            // the box is 30ft x 30ft x 30ft
            // the placement point is the center of the bottom face of the box
            var boxOffsetTop    = Vector.ByCoordinates(15, 15, 30).AsPoint().InDynamoUnits().AsVector();
            var boxOffsetBottom = Vector.ByCoordinates(-15, -15, 0).AsPoint().InDynamoUnits().AsVector();

            min.ShouldBeApproximately((Point)pt.Translate(boxOffsetBottom));
            max.ShouldBeApproximately((Point)pt.Translate(boxOffsetTop));
        }
예제 #14
0
        public void StructuralFraming_Column_BadArgs()
        {
            // A tilted column
            var start  = Point.ByCoordinates(1, 2, 3);
            var end    = Point.ByCoordinates(1, 4, 12);
            var line   = Line.ByStartPointEndPoint(start, end);
            var level  = Level.ByElevation(3);
            var famTyp = FamilyType.ByName("W12X26");

            Assert.Throws <System.ArgumentNullException>(
                () => StructuralFraming.ColumnByCurve(null, level, famTyp));
            Assert.Throws <System.ArgumentNullException>(
                () => StructuralFraming.ColumnByCurve(line, null, famTyp));
            Assert.Throws <System.ArgumentNullException>(
                () => StructuralFraming.ColumnByCurve(line, level, null));

            // Updside down column
            end   = Point.ByCoordinates(1, 2, 3);
            start = Point.ByCoordinates(1, 4, 12);
            line  = Line.ByStartPointEndPoint(start, end);

            Assert.Throws <Exception>(() => StructuralFraming.ColumnByCurve(line, level, famTyp));
        }
예제 #15
0
        public void StructuralFraming_Beam_ValidArgs()
        {
            var start  = Point.ByCoordinates(1, 2, 3);
            var end    = Point.ByCoordinates(5, 8, 3);
            var line   = Line.ByStartPointEndPoint(start, end);
            var level  = Level.ByElevation(3);
            var famTyp = FamilyType.ByName("W12X26");

            var lineBeam = StructuralFraming.BeamByCurve(line, level, famTyp);

            Assert.NotNull(lineBeam);
            Assert.NotNull(lineBeam.InternalElement);
            Assert.IsTrue(DocumentManager.Instance.ElementExistsInDocument(
                              new ElementUUID(lineBeam.InternalElement.UniqueId)));

            var curve = Arc.ByCenterPointRadiusAngle(Point.Origin(), 20, 0, 90, Vector.ZAxis());

            var arcBeam = StructuralFraming.BeamByCurve(curve, level, famTyp);

            Assert.NotNull(arcBeam);
            Assert.NotNull(arcBeam.InternalElement);
            Assert.IsTrue(DocumentManager.Instance.ElementExistsInDocument(
                              new ElementUUID(lineBeam.InternalElement.UniqueId)));
        }
예제 #16
0
 public void ByName_BadArgs()
 {
     Assert.Throws(typeof(Exception), () => FamilyType.ByName("Turtle.BoxTurtle"));
     Assert.Throws(typeof(System.ArgumentNullException), () => FamilyType.ByName(null));
 }