Пример #1
0
        /// <summary>
        /// Create a Revit Wall from a guiding Curve, height, Level, and WallType
        /// </summary>
        /// <param name="curve"></param>
        /// <param name="height"></param>
        /// <param name="level"></param>
        /// <param name="wallType"></param>
        /// <returns></returns>
        public static Wall ByCurveAndHeight(Autodesk.DesignScript.Geometry.Curve curve, double height, Level level, WallType wallType)
        {
            if (curve == null)
            {
                throw new ArgumentNullException("curve");
            }

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

            if (wallType == null)
            {
                throw new ArgumentNullException("wallType");
            }

            if (height < 1e-6 || height > 30000)
            {
                throw new ArgumentException("The height must be greater than 0 and less that 30000 ft.  You provided a height of " + height + " ft.");
            }


            return(new Wall(curve.ToRevitType(), wallType.InternalWallType, level.InternalLevel, height, 0.0, false, false));
        }
Пример #2
0
        /// <summary>
        /// Create a Revit Structural Member - a special FamilyInstance
        /// </summary>
        /// <param name="curve">The curve path for the structural member</param>
        /// <param name="upVector">The up vector for the element - this is required to determine the orientation of the element</param>
        /// <param name="level">The level on which the member should appear</param>
        /// <param name="structuralType">The type of the structural element - a beam, column, etc</param>
        /// <param name="structuralFamilySymbol">The FamilySymbol representing the structural type</param>
        /// <returns></returns>
        public static StructuralFraming ByCurveLevelUpVectorAndType(Autodesk.DesignScript.Geometry.Curve curve, Level level, Autodesk.DesignScript.Geometry.Vector upVector, StructuralType structuralType, FamilySymbol structuralFamilySymbol)
        {
            if (curve == null)
            {
                throw new ArgumentNullException("curve");
            }

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

            if (upVector == null)
            {
                throw new ArgumentNullException("upVector");
            }

            if (structuralFamilySymbol == null)
            {
                throw new ArgumentNullException("structuralFamilySymbol");
            }

            return(new StructuralFraming(curve.ToRevitType(), upVector.ToXyz(), level.InternalLevel,
                                         structuralType.ToRevitType(), structuralFamilySymbol.InternalFamilySymbol));
        }
Пример #3
0
        /// <summary>
        /// Create a Revit Wall from a guiding Curve, height, Level, and WallType
        /// </summary>
        /// <param name="curve"></param>
        /// <param name="height"></param>
        /// <param name="level"></param>
        /// <param name="wallType"></param>
        /// <returns></returns>
        public static Wall ByCurveAndHeight(Autodesk.DesignScript.Geometry.Curve curve, double height, Level level, WallType wallType)
        {
            if (curve == null)
            {
                throw new ArgumentNullException("curve");
            }

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

            if (wallType == null)
            {
                throw new ArgumentNullException("wallType");
            }

            height = height * UnitConverter.DynamoToHostFactor(UnitType.UT_Length);

            if (height < 1e-6 || height > 30000)
            {
                throw new ArgumentException(string.Format(Properties.Resources.InvalidWallHeight, height));
            }

            return(new Wall(curve.ToRevitType(), wallType.InternalWallType, level.InternalLevel, height, 0.0, false, false));
        }
Пример #4
0
        /// <summary>
        /// Construct a Revit ModelCurve element from a Curve
        /// </summary>
        /// <param name="curve"></param>
        /// <returns></returns>
        public static ModelCurve ByCurve(Autodesk.DesignScript.Geometry.Curve curve)
        {
            if (curve == null)
            {
                throw new ArgumentNullException("curve");
            }

            return(new ModelCurve(ExtractLegalRevitCurve(curve), false));
        }
Пример #5
0
        // <summary>
        /// Construct a Revit ModelCurve element from a Curve
        /// </summary>
        /// <param name="curve"></param>
        /// <returns></returns>
        public static ModelCurve ReferenceCurveByCurve(Autodesk.DesignScript.Geometry.Curve curve)
        {
            if (curve == null)
            {
                throw new ArgumentNullException("curve");
            }

            return(new ModelCurve(curve.ToRevitType(), true));
        }
Пример #6
0
        /// <summary>
        /// Construct a Revit ModelCurve element from a Curve
        /// </summary>
        /// <param name="curve"></param>
        /// <returns></returns>
        public static ModelCurve ReferenceCurveByCurve(Autodesk.DesignScript.Geometry.Curve curve)
        {
            if (curve == null)
            {
                throw new ArgumentNullException("curve");
            }

            if (!Document.IsFamilyDocument)
            {
                throw new Exception("Revit can only create a ReferenceCurve in a family document!");
            }

            return(new ModelCurve(ExtractLegalRevitCurve(curve), true));
        }
Пример #7
0
        /// <summary>
        /// Construct a Revit ModelCurve element from a Curve
        /// </summary>
        /// <param name="curve"></param>
        /// <returns></returns>
        public static ModelCurve ReferenceCurveByCurve(Autodesk.DesignScript.Geometry.Curve curve)
        {
            if (curve == null)
            {
                throw new ArgumentNullException("curve");
            }

            if (!Document.IsFamilyDocument)
            {
                throw new Exception(Properties.Resources.ReferenceCurveCreationFailure);
            }

            return(new ModelCurve(ExtractLegalRevitCurve(curve), true));
        }
Пример #8
0
        private static Autodesk.Revit.DB.Curve ExtractLegalRevitCurve(Autodesk.DesignScript.Geometry.Curve curve)
        {
            // PB:  PolyCurves may have discontinuities that prevent them from being turned into legal Revit ModelCurves.
            // Moreover, a single ModelCurve may not be a composite or multiple curves.

            // One could add a static method to ModelCurve that is an overload of ByCurve - ModelCurve[] ByCurve(PolyCurve).
            // But, this adds an unnecessary high level of complexity to the Element rebinding code.  Hence, we will go the
            // more straightforward route of just providing an informative error message to the user.
            if (curve is PolyCurve)
            {
                throw new Exception(Properties.Resources.PolyCurvesConversionError);
            }

            return(curve.ToRevitType());
        }
Пример #9
0
        /// <summary>
        /// Create a Revit Wall from a guiding Curve, start Level, end Level, and WallType
        /// </summary>
        /// <param name="c"></param>
        /// <param name="startLevel"></param>
        /// <param name="endLevel"></param>
        /// <param name="wallType"></param>
        /// <returns></returns>
        public static Wall ByCurveAndLevels(Autodesk.DesignScript.Geometry.Curve c, Level startLevel, Level endLevel, WallType wallType)
        {
            if (endLevel == null)
            {
                throw new ArgumentNullException("endLevel");
            }

            if (startLevel == null)
            {
                throw new ArgumentNullException("startLevel");
            }

            var height = endLevel.Elevation - startLevel.Elevation;

            return(ByCurveAndHeight(c, height, startLevel, wallType));
        }