/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
// <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)); }
/// <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)); }
/// <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)); }
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()); }
/// <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)); }