public static IEnumerable <XYZ> OffsetPoints(List <XYZ> pts, double offset, XYZ normal) { CurveLoop curveLoop = CreateCurveLoop(pts); CurveLoop curveLoop2 = CurveLoop.CreateViaOffset(curveLoop, offset, normal); return(curveLoop2.Select <Curve, XYZ>(c => c.GetEndPoint(0))); }
public static CurveLoop CreateTransformed(this CurveLoop curveLoop, Transform transform) { var curves = curveLoop .Select(x => x.CreateTransformed(transform)) .ToList(); return(CurveLoop.Create(curves)); }
public Polycurve CurveLoopToSpeckle(CurveLoop loop, string units = null) { var polycurve = new Polycurve(); polycurve.units = units ?? ModelUnits; polycurve.closed = !loop.IsOpen(); polycurve.length = units == Units.None ? loop.GetExactLength() : ScaleToSpeckle(loop.GetExactLength()); polycurve.segments.AddRange(loop.Select(x => CurveToSpeckle(x))); return(polycurve); }
/***************************************************/ public static oM.Geometry.PolyCurve FromRevit(this CurveLoop curveLoop) { if (curveLoop == null) { return(null); } return(new oM.Geometry.PolyCurve { Curves = curveLoop.Select(x => x.IFromRevit()).ToList() }); }
public Polycurve CurveLoopToSpeckle(CurveLoop loop) { var polycurve = new Polycurve(); polycurve.units = ModelUnits; polycurve.closed = !loop.IsOpen(); polycurve.length = ScaleToSpeckle(loop.GetExactLength()); polycurve.segments.AddRange(loop.Select(x => CurveToSpeckle(x))); return(polycurve); }
static public Line FlattenIntoLineBound(this CurveLoop curveLoop, double height = 0) { IList <Curve> flattenCurves = curveLoop.Select(c => c.Flatten(height)).Where(c => c != null).ToList(); double maxDist = double.MinValue; Line flattenLine = null; foreach (Curve curve1 in flattenCurves) { foreach (Curve curve2 in flattenCurves) { XYZ c1P0 = curve1.GetEndPoint(0); XYZ c1P1 = curve1.GetEndPoint(1); XYZ c2P0 = curve2.GetEndPoint(0); XYZ c2P1 = curve2.GetEndPoint(1); double dist = c1P0.DistanceTo(c1P1); if (dist > maxDist && dist > 0.05) { maxDist = dist; flattenLine = Line.CreateBound(c1P0, c1P1); } dist = c1P0.DistanceTo(c2P0); if (dist > maxDist && dist > 0.05) { maxDist = dist; flattenLine = Line.CreateBound(c1P0, c2P0); } dist = c1P0.DistanceTo(c2P1); if (dist > maxDist && dist > 0.05) { maxDist = dist; flattenLine = Line.CreateBound(c1P0, c2P1); } } } return(flattenLine); }
private static Polygon ToPolygon(this CurveLoop curveLoop, bool scaleToMeters = false) { return(new Polygon(curveLoop.Select(l => l.GetEndPoint(0).ToVector3(scaleToMeters)).ToList())); }
CurveLoop GetOuterLoopOfRoomFromCreateViaOffset( View view, IList <IList <BoundarySegment> > sloops) { Document doc = view.Document; CurveLoop loop = null; IList <double> wallthicknessList = new List <double>(); foreach (IList <BoundarySegment> sloop in sloops) { loop = new CurveLoop(); foreach (BoundarySegment s in sloop) { loop.Append(s.GetCurve()); ElementType type = doc.GetElement( s.ElementId) as ElementType; Element e = doc.GetElement(s.ElementId); double thickness = (e is Wall) ? (e as Wall).Width : 0; // Room separator; any other exceptions need including?? wallthicknessList.Add(thickness * _wall_width_factor); } // Skip out after first sloop - ignore // rooms with holes and disjunct parts break; } int n = loop.Count(); string slength = string.Join(",", loop.Select <Curve, string>( c => c.Length.ToString("#.##"))); int m = wallthicknessList.Count(); string sthickness = string.Join(",", wallthicknessList.Select <double, string>( d => d.ToString("#.##"))); Debug.Print( "{0} curves with lengths {1} and {2} thicknesses {3}", n, slength, m, sthickness); CreateModelCurves(view, loop); bool flip_normal = true; XYZ normal = flip_normal ? -XYZ.BasisZ : XYZ.BasisZ; CurveLoop room_outer_loop = CurveLoop.CreateViaOffset( loop, wallthicknessList, normal); CreateModelCurves(view, room_outer_loop); //CurveLoop newloop = new CurveLoop(); //foreach( Curve curve in loop2 ) //{ // IList<XYZ> points = curve.Tessellate(); // for( int ip = 0; ip < points.Count - 1; ip++ ) // { // Line l = Line.CreateBound( // points[ ip ], points[ ip + 1 ] ); // newloop.Append( l ); // } //} return(room_outer_loop); }