public void Rotate_ZAxis()
        {
            var famSym  = FamilyType.ByName("Box");
            var pt      = Point.ByCoordinates(0, 1, 2);
            var famInst = FamilyInstance.ByPoint(famSym, pt);

            Assert.NotNull(famInst);

            var transform = famInst.InternalFamilyInstance.GetTransform();

            double[] rotationAngles;
            TransformUtils.ExtractEularAnglesFromTransform(transform, out rotationAngles);
            Assert.AreEqual(0.0, rotationAngles[0]);

            RevitServices.Persistence.DocumentManager.Instance.CurrentDBDocument.Regenerate();

            famInst.SetRotation(30);
            transform = famInst.InternalFamilyInstance.GetTransform();
            TransformUtils.ExtractEularAnglesFromTransform(transform, out rotationAngles);
            Assert.AreEqual(30.0, rotationAngles[0] * 180 / Math.PI, 1.0e-6);

            famInst.SetRotation(60);
            transform = famInst.InternalFamilyInstance.GetTransform();
            TransformUtils.ExtractEularAnglesFromTransform(transform, out rotationAngles);
            Assert.AreEqual(60.0, rotationAngles[0] * 180 / Math.PI, 1.0e-6);
        }
        public void FacingOrientation()
        {
            var famSym  = FamilyType.ByName("Box");
            var pt      = Point.ByCoordinates(0, 1, 2);
            var famInst = FamilyInstance.ByPoint(famSym, pt);

            Assert.NotNull(famInst);

            var dir = famInst.FacingOrientation;

            dir.IsAlmostEqualTo(Vector.ByCoordinates(0.0, 0.0, 1.0));
        }
        public void ByCoordinates_ProducesValidFamilyInstanceWithCorrectLocation()
        {
            var famSym  = FamilyType.ByName("Box");
            var famInst = FamilyInstance.ByCoordinates(famSym, 0, 1, 2);

            Assert.NotNull(famInst);

            var position = famInst.Location;

            position.ShouldBeApproximately(Point.ByCoordinates(0, 1, 2));

            // no unit conversion
            var internalPos =
                InternalLocation(famInst.InternalElement as Autodesk.Revit.DB.FamilyInstance);

            (internalPos * UnitConverter.HostToDynamoFactor(UnitType.UT_Length)).ShouldBeApproximately(
                Point.ByCoordinates(0, 1, 2));
        }
Esempio n. 4
0
        public void CanConvertProtoToRevitType()
        {
            var famSym  = FamilySymbol.ByName("Box");
            var pt      = Point.ByCoordinates(0, 1, 2);
            var famInst = FamilyInstance.ByPoint(famSym, 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));
        }
Esempio n. 5
0
        public void CanConvertRevitToProtoType()
        {
            var famSym  = FamilySymbol.ByName("Box");
            var pt      = Point.ByCoordinates(0, 1, 2);
            var famInst = FamilyInstance.ByPoint(famSym, 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));
        }
        public void ByCoordinates_NullFamilySymbol()
        {
            var pt = Point.ByCoordinates(0, 1, 2);

            Assert.Throws(typeof(System.ArgumentNullException), () => FamilyInstance.ByCoordinates(null, 0, 1, 2));
        }
        public void ByPoint_NullPoint()
        {
            var famSym = FamilyType.ByName("Box");

            Assert.Throws(typeof(System.ArgumentNullException), () => FamilyInstance.ByPoint(famSym, null));
        }