Exemplo n.º 1
0
        /// <summary>
        /// Create a column.
        /// </summary>
        /// <param name="curve">The curve which defines the center line of the column.</param>
        /// <param name="level">The level with which you'd like the column to be associated.</param>
        /// <param name="structuralColumnType">The structural column type representing the column.</param>
        /// <returns></returns>
        public static StructuralFraming ColumnByCurve(
            Autodesk.DesignScript.Geometry.Curve curve, Revit.Elements.Level level, Revit.Elements.FamilySymbol structuralColumnType)
        {
            if (curve == null)
            {
                throw new System.ArgumentNullException("curve");
            }

            if (level == null)
            {
                throw new System.ArgumentNullException("level");
            }

            if (structuralColumnType == null)
            {
                throw new System.ArgumentNullException("structuralColumnType");
            }

            var start = curve.PointAtParameter(0);
            var end   = curve.PointAtParameter(1);

            // Revit will throw an exception if you attempt to create a column whose
            // base is above its top.
            if (end.Z <= start.Z)
            {
                throw new Exception("The end of the curve for creating a column should be above the start of the curve.");
            }

            return(new StructuralFraming(curve.ToRevitType(), level.InternalLevel, Autodesk.Revit.DB.Structure.StructuralType.Column, structuralColumnType.InternalFamilySymbol));
        }
Exemplo n.º 2
0
        public void ByCoordinates_ProducesValidFamilyInstanceWithCorrectLocation()
        {
            var famSym  = FamilySymbol.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).ShouldBeApproximately(
                Point.ByCoordinates(0, 1, 2));
        }
Exemplo n.º 3
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));
        }
Exemplo n.º 4
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));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Create a brace.
        /// </summary>
        /// <param name="curve">The cruve which defines the center line of the brace.</param>
        /// <param name="level">The level with which you'd like the brace to be associated.</param>
        /// <param name="structuralFramingType">The structural framing type representing the brace.</param>
        /// <returns></returns>
        public static StructuralFraming BraceByCurve(Autodesk.DesignScript.Geometry.Curve curve, Revit.Elements.Level level, Revit.Elements.FamilySymbol structuralFramingType)
        {
            if (curve == null)
            {
                throw new System.ArgumentNullException("curve");
            }

            if (level == null)
            {
                throw new System.ArgumentNullException("level");
            }

            if (structuralFramingType == null)
            {
                throw new System.ArgumentNullException("structuralFramingType");
            }

            return(new StructuralFraming(curve.ToRevitType(), level.InternalLevel, Autodesk.Revit.DB.Structure.StructuralType.Brace, structuralFramingType.InternalFamilySymbol));
        }
Exemplo n.º 6
0
        public void ByPoint_NullPoint()
        {
            var famSym = FamilySymbol.ByName("Box");

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