/// <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> /// Make a Revit SketchPlane given a plane /// </summary> /// <param name="plane"></param> /// <returns></returns> public static SketchPlane ByPlane(Autodesk.DesignScript.Geometry.Plane plane) { if (plane == null) { throw new ArgumentNullException("plane"); } return(new SketchPlane(plane.ToPlane())); }
/// <summary> /// Create an Advance Steel Rectangular Wall by defining the extents of the face of the wall by Dynamo Plane /// </summary> /// <param name="plane"> Input Dynamo Plane to insert Wall</param> /// <param name="length"> Input Wall Length</param> /// <param name="height"> Input Wall Height</param> /// <param name="thickness"> Input Wall Thickness</param> /// <param name="additionalConcParameters"> Optional Input Build Properties </param> /// <returns name="walls"> walls</returns> public static Walls FaceByLengthHeightByPlane(Autodesk.DesignScript.Geometry.Plane plane, double length, double height, double thickness, [DefaultArgument("null")] List <Property> additionalConcParameters) { additionalConcParameters = PreSetDefaults(additionalConcParameters); return(new Walls(Utils.ToAstPoint(plane.Origin, true), Utils.ToInternalDistanceUnits(length, true), Utils.ToInternalDistanceUnits(height, true), Utils.ToInternalDistanceUnits(thickness, true), Utils.ToAstVector3d(plane.Normal, true), additionalConcParameters)); }
/// <summary> /// Get intersection point of Steel object system line with Dynamo plane /// </summary> /// <param name="steelObject"> Advance Steel element</param> /// <param name="intersectionPlane"> Dynamo Plane to intersect with Steel body</param> /// <returns name="point"> point formed by cutting the system line through a plane</returns> public static Autodesk.DesignScript.Geometry.Point CutSystemLineByPlane(AdvanceSteel.Nodes.SteelDbObject steelObject, Autodesk.DesignScript.Geometry.Plane intersectionPlane) { Autodesk.DesignScript.Geometry.Point ret = Autodesk.DesignScript.Geometry.Point.ByCoordinates(0, 0, 0); using (var ctx = new SteelServices.DocContext()) { if (steelObject != null || intersectionPlane != null) { FilerObject filerObj = Utils.GetObject(steelObject.Handle); Plane cutPlane = Utils.ToAstPlane(intersectionPlane, true); if (filerObj != null) { AtomicElement selectedObj = filerObj as AtomicElement; if (selectedObj.IsKindOf(FilerObject.eObjectType.kBeam)) { Autodesk.AdvanceSteel.Modelling.Beam passedBeam = selectedObj as Autodesk.AdvanceSteel.Modelling.Beam; Line3d line = new Line3d(passedBeam.GetPointAtStart(), passedBeam.GetPointAtEnd()); Point3d[] intPts = new Point3d[] { }; cutPlane.IntersectWith(line, ref intPts, new Tol()); if (intPts.Length > 0) { ret = Utils.ToDynPoint(intPts[0], true); } else { throw new System.Exception("No Intersection point found on steel object with current plane"); } } } else { throw new System.Exception("No Object found via registered handle"); } } else { throw new System.Exception("No Steel Object found or Plane is Null"); } } return(ret); }
/// <summary> /// Get line segments of steel body that interected with plane /// </summary> /// <param name="steelObject"> Advance Steel element</param> /// <param name="bodyResolution"> Set Steel body display resolution</param> /// <param name="intersectionPlane"> Dynamo Plane to intersect with Steel body</param> /// <returns name="lines"> list of lines that form the section created by passing the steel object through the plane</returns> public static List <Autodesk.DesignScript.Geometry.Line> CutElementByPlane(AdvanceSteel.Nodes.SteelDbObject steelObject, int bodyResolution, Autodesk.DesignScript.Geometry.Plane intersectionPlane) { List <Autodesk.DesignScript.Geometry.Line> ret = new List <Autodesk.DesignScript.Geometry.Line>() { }; using (var ctx = new SteelServices.DocContext()) { if (steelObject != null || intersectionPlane != null) { FilerObject filerObj = Utils.GetObject(steelObject.Handle); Plane cutPlane = Utils.ToAstPlane(intersectionPlane, true); if (filerObj != null) { AtomicElement selectedObj = filerObj as AtomicElement; ModelerBody modelerTestBody = selectedObj.GetModeler((BodyContext.eBodyContext)bodyResolution); LineSeg3d[] segs = null; modelerTestBody.IntersectWith(cutPlane, out segs); for (int i = 0; i < segs.Length; i++) { Autodesk.DesignScript.Geometry.Point dynStartPoint = Utils.ToDynPoint(segs[i].StartPoint, true); Autodesk.DesignScript.Geometry.Point dynEndPoint = Utils.ToDynPoint(segs[i].EndPoint, true); ret.Add(Autodesk.DesignScript.Geometry.Line.ByStartPointEndPoint(dynStartPoint, dynEndPoint)); } } else { throw new System.Exception("No Object found via registered handle"); } } else { throw new System.Exception("No Steel Object found or Plane is Null"); } } return(ret); }
/// <summary> /// Get Plane from planar objects like - plate, grating, slab or isolated footing /// </summary> /// <param name="steelObject"> Advance Steel element</param> /// <returns name="plane"> returns a plane from plannar objects - plate, slab, footing isolated or grating</returns> public static Autodesk.DesignScript.Geometry.Plane GetPlane(AdvanceSteel.Nodes.SteelDbObject steelObject) { Autodesk.DesignScript.Geometry.Plane ret = null; using (var ctx = new SteelServices.DocContext()) { if (steelObject != null) { FilerObject filerObj = Utils.GetObject(steelObject.Handle); if (filerObj != null) { if (filerObj.IsKindOf(FilerObject.eObjectType.kPlate) || filerObj.IsKindOf(FilerObject.eObjectType.kSlab) || filerObj.IsKindOf(FilerObject.eObjectType.kFootingIsolated) || filerObj.IsKindOf(FilerObject.eObjectType.kGrating)) { PlateBase selectedObj = filerObj as PlateBase; Plane plane = selectedObj.DefinitionPlane; ret = Utils.ToDynPlane(plane, true); } else { throw new System.Exception("Wrong type of Steel Object found, must be a Plate, Grating, Slab or Footing Isolated - Planner Object"); } } else { throw new System.Exception("No Object found via registered handle"); } } else { throw new System.Exception("No Steel Object found"); } } return(ret); }