public Arc ArcToSpeckle(DB.Arc arc, string units = null) { var u = units ?? ModelUnits; // see https://forums.autodesk.com/t5/revit-api-forum/how-to-retrieve-startangle-and-endangle-of-arc-object/td-p/7637128 var arcPlane = DB.Plane.CreateByOriginAndBasis(arc.Center, arc.XDirection, arc.YDirection); XYZ center = arc.Center; XYZ dir0 = (arc.GetEndPoint(0) - center).Normalize(); XYZ dir1 = (arc.GetEndPoint(1) - center).Normalize(); XYZ start = arc.Evaluate(0, true); XYZ end = arc.Evaluate(1, true); XYZ mid = arc.Evaluate(0.5, true); double startAngle = arc.XDirection.AngleOnPlaneTo(dir0, arc.Normal); double endAngle = arc.XDirection.AngleOnPlaneTo(dir1, arc.Normal); var a = new Arc(PlaneToSpeckle(arcPlane, u), u == Units.None ? arc.Radius : ScaleToSpeckle(arc.Radius), startAngle, endAngle, endAngle - startAngle, u); a.endPoint = PointToSpeckle(end, u); a.startPoint = PointToSpeckle(start, u); a.midPoint = PointToSpeckle(mid, u); a.length = ScaleToSpeckle(arc.Length); a.domain = new Interval(arc.GetEndParameter(0), arc.GetEndParameter(1)); return(a); }
// Arc // Rh Capture can be a circle OR an arc public Base ArcToSpeckle(ArcCurve a, string units = null) { var u = units ?? ModelUnits; if (a.IsClosed) { RH.Circle preCircle; a.TryGetCircle(out preCircle); Circle myCircle = CircleToSpeckle(preCircle, u); myCircle.domain = IntervalToSpeckle(a.Domain); myCircle.length = a.GetLength(); myCircle.bbox = BoxToSpeckle(new RH.Box(a.GetBoundingBox(true)), u); return(myCircle); } else { RH.Arc preArc; a.TryGetArc(out preArc); Arc myArc = ArcToSpeckle(preArc, u); myArc.domain = IntervalToSpeckle(a.Domain); myArc.length = a.GetLength(); myArc.bbox = BoxToSpeckle(new RH.Box(a.GetBoundingBox(true)), u); return(myArc); } }
public Arc ArcToSpeckle(DB.Arc arc) { // see https://forums.autodesk.com/t5/revit-api-forum/how-to-retrieve-startangle-and-endangle-of-arc-object/td-p/7637128 var arcPlane = DB.Plane.CreateByNormalAndOrigin(arc.Normal, arc.Center); XYZ center = arc.Center; XYZ dir0 = (arc.GetEndPoint(0) - center).Normalize(); XYZ dir1 = (arc.GetEndPoint(1) - center).Normalize(); XYZ start = arc.Evaluate(0, true); XYZ end = arc.Evaluate(1, true); XYZ mid = arc.Evaluate(0.5, true); double startAngle = dir0.AngleOnPlaneTo(arc.XDirection, arc.Normal); double endAngle = dir1.AngleOnPlaneTo(arc.XDirection, arc.Normal); var a = new Arc(PlaneToSpeckle(arcPlane), ScaleToSpeckle(arc.Radius), startAngle, endAngle, endAngle - startAngle, ModelUnits); a.endPoint = PointToSpeckle(end); a.startPoint = PointToSpeckle(start); a.midPoint = PointToSpeckle(mid); return(a); }
// Gh Capture public Arc ArcToSpeckle(RH.Arc a) { Arc arc = new Arc(PlaneToSpeckle(a.Plane), a.Radius, a.StartAngle, a.EndAngle, a.Angle, ModelUnits); arc.endPoint = PointToSpeckle(a.EndPoint); arc.startPoint = PointToSpeckle(a.StartPoint); arc.midPoint = PointToSpeckle(a.MidPoint); arc.domain = new Interval(0, 1); return(arc); }
// Gh Capture public Arc ArcToSpeckle(RH.Arc a, string units = null) { var u = units ?? ModelUnits; Arc arc = new Arc(PlaneToSpeckle(a.Plane, u), a.Radius, a.StartAngle, a.EndAngle, a.Angle, u); arc.endPoint = PointToSpeckle(a.EndPoint, u); arc.startPoint = PointToSpeckle(a.StartPoint, u); arc.midPoint = PointToSpeckle(a.MidPoint, u); arc.domain = new Interval(0, 1); arc.length = a.Length; arc.bbox = BoxToSpeckle(new RH.Box(a.BoundingBox()), u); return(arc); }
/// <summary> /// SpeckleArc to DS Arc /// </summary> /// <param name="a"></param> /// <returns></returns> public DS.Arc ArcToNative(Arc a) { using (DS.Plane basePlane = PlaneToNative(a.plane)) using (DS.Point startPoint = (DS.Point)basePlane.Origin.Translate(basePlane.XAxis, ScaleToNative(a.radius.Value, a.units))) { var arc = DS.Arc.ByCenterPointStartPointSweepAngle( basePlane.Origin, startPoint, a.angleRadians.Value.ToDegrees(), basePlane.Normal ); return(arc.SetDynamoProperties <DS.Arc>(GetDynamicMembersFromBase(a))); } }
public ArcCurve ArcToNative(Arc a) { RH.Arc arc = new RH.Arc(PlaneToNative(a.plane), ScaleToNative((double)a.radius, a.units), (double)a.angleRadians); arc.StartAngle = (double)a.startAngle; arc.EndAngle = (double)a.endAngle; var myArc = new ArcCurve(arc); if (a.domain != null) { myArc.Domain = IntervalToNative(a.domain); } return(myArc); }
public ArcCurve ArcToNative(Arc a) { RH.Arc arc = new RH.Arc(PlaneToNative(a.plane), ScaleToNative((double)a.radius, a.units), (double)a.angleRadians); arc.StartAngle = (double)a.startAngle; arc.EndAngle = (double)a.endAngle; if (!arc.IsValid) // try with different method if not valid { arc = new RH.Arc(PointToNative(a.startPoint).Location, PointToNative(a.midPoint).Location, PointToNative(a.endPoint).Location); } var myArc = new ArcCurve(arc); if (a.domain != null) { myArc.Domain = IntervalToNative(a.domain); } return(myArc); }
public DB.Arc ArcToNative(Arc arc) { double startAngle, endAngle; if (arc.startAngle > arc.endAngle) { startAngle = (double)arc.endAngle; endAngle = (double)arc.startAngle; } else { startAngle = (double)arc.startAngle; endAngle = (double)arc.endAngle; } var plane = PlaneToNative(arc.plane); return(DB.Arc.Create(PointToNative(arc.startPoint), PointToNative(arc.endPoint), PointToNative(arc.midPoint))); //return Arc.Create( plane.Origin, (double) arc.Radius * Scale, startAngle, endAngle, plane.XVec, plane.YVec ); }
/// <summary> /// DS Arc to SpeckleArc /// </summary> /// <param name="a"></param> /// <returns></returns> public Arc ArcToSpeckle(DS.Arc a) { using (DS.Vector xAxis = DS.Vector.ByTwoPoints(a.CenterPoint, a.StartPoint)) using (DS.Plane basePlane = DS.Plane.ByOriginNormalXAxis(a.CenterPoint, a.Normal, xAxis)) { var arc = new Arc( PlaneToSpeckle(basePlane), a.Radius, 0, // This becomes 0 as arcs are interpreted to start from the plane's X axis. a.SweepAngle.ToRadians(), a.SweepAngle.ToRadians(), ModelUnits ); CopyProperties(arc, a); return(arc); } }
// Arc // Rh Capture can be a circle OR an arc public Base ArcToSpeckle(ArcCurve a) { if (a.IsClosed) { RH.Circle preCircle; a.TryGetCircle(out preCircle); Circle myCircle = CircleToSpeckle(preCircle); myCircle.domain = IntervalToSpeckle(a.Domain); return(myCircle); } else { RH.Arc preArc; a.TryGetArc(out preArc); Arc myArc = ArcToSpeckle(preArc); myArc.domain = IntervalToSpeckle(a.Domain); return(myArc); } }
/// <summary> /// DS Arc to SpeckleArc /// </summary> /// <param name="a"></param> /// <returns></returns> public Arc ArcToSpeckle(DS.Arc a, string units = null) { var u = units ?? ModelUnits; using (DS.Vector xAxis = DS.Vector.ByTwoPoints(a.CenterPoint, a.StartPoint)) using (DS.Plane basePlane = DS.Plane.ByOriginNormalXAxis(a.CenterPoint, a.Normal, xAxis)) { var arc = new Arc( PlaneToSpeckle(basePlane, u), a.Radius, 0, // This becomes 0 as arcs are interpreted to start from the plane's X axis. a.SweepAngle.ToRadians(), a.SweepAngle.ToRadians(), u ); CopyProperties(arc, a); arc.length = a.Length; arc.bbox = BoxToSpeckle(a.BoundingBox.ToCuboid(), u); return(arc); } }