/// <summary> /// Construct a Revit DetailCurve element from a curve /// </summary> /// <param name="view">View to place the detail curve on</param> /// <param name="curve">Curve to create detailcurve from</param> /// <returns></returns> public static DetailCurve ByCurve(Revit.Elements.Views.View view, Autodesk.DesignScript.Geometry.Curve curve) { if (!view.IsAnnotationView()) { throw new Exception(Properties.Resources.ViewDoesNotSupportAnnotations); } if (!curve.IsPlanar) { throw new Exception(Properties.Resources.CurveIsNotPlanar); } if (curve is Autodesk.DesignScript.Geometry.PolyCurve) { throw new Exception(Properties.Resources.PolyCurvesConversionError); } // Pull Curve onto the XY plane to place it correctly on the view. Autodesk.DesignScript.Geometry.Plane XYplane = Autodesk.DesignScript.Geometry.Plane.XY(); Autodesk.DesignScript.Geometry.Curve flattenedCurve = curve.PullOntoPlane(XYplane); Autodesk.Revit.DB.View revitView = (Autodesk.Revit.DB.View)view.InternalElement; return(new DetailCurve(revitView, flattenedCurve.ToRevitType())); }
/// <summary> /// Set Geometry Curve /// </summary> public void SetCurve(Autodesk.DesignScript.Geometry.Curve curve) { Autodesk.Revit.DB.Document document = DocumentManager.Instance.CurrentDBDocument; TransactionManager.Instance.EnsureInTransaction(document); this.InternalCurveElement.SetGeometryCurve(curve.ToRevitType(), true); TransactionManager.Instance.TransactionTaskDone(); }
private static Curve CreateReversed(Curve curve) { Autodesk.Revit.DB.Curve orig = curve.ToRevitType(); var app = DocumentManager.Instance.CurrentUIApplication; if (orig is Line) { var line = Line.CreateBound( orig.GetEndPoint(1), orig.GetEndPoint(0)); return(line.ToProtoType()); } else if (orig is Arc) { var arc = Arc.Create(orig.GetEndPoint(1), orig.GetEndPoint(0), orig.Evaluate(0.5, true)); return(arc.ToProtoType()); } else { throw new Exception( "CreateReversedCurve - Unreachable"); } }
/// <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.FamilyType 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(Properties.Resources.InvalidColumnBaseLocation); } return(new StructuralFraming(curve.ToRevitType(), level.InternalLevel, Autodesk.Revit.DB.Structure.StructuralType.Column, structuralColumnType.InternalFamilySymbol)); }
public static StructuralFraming ByCurveLevelUpVectorAndType(Autodesk.DesignScript.Geometry.Curve curve, Level level, Autodesk.DesignScript.Geometry.Vector upVector, StructuralType structuralType, FamilyType structuralFramingType) { if (curve == null) { throw new System.ArgumentNullException("curve"); } if (level == null) { throw new System.ArgumentNullException("level"); } if (upVector == null) { throw new System.ArgumentNullException("upVector"); } if (structuralFramingType == null) { throw new System.ArgumentNullException("structuralFramingType"); } return(new StructuralFraming(curve.ToRevitType(), upVector.ToXyz(), level.InternalLevel, structuralType.ToRevitType(), structuralFramingType.InternalFamilySymbol)); }
/// <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.FamilyType 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)); }