// featurelines public Polycurve FeatureLineToSpeckle(CivilDB.FeatureLine featureLine) { var polycurve = new Polycurve() { closed = featureLine.Closed }; // extract segment curves var segments = new List <ICurve>(); var exploded = new DBObjectCollection(); featureLine.Explode(exploded); for (int i = 0; i < exploded.Count; i++) { segments.Add((ICurve)ConvertToSpeckle(exploded[i])); } polycurve.segments = segments; // TODO: additional params to attach try{ var points = featureLine.GetPoints(Autodesk.Civil.FeatureLinePointType.AllPoints); var grade = new Interval(featureLine.MinGrade, featureLine.MaxGrade); var elevation = new Interval(featureLine.MinElevation, featureLine.MaxElevation); var name = featureLine.DisplayName; } catch {} return(polycurve); }
public Polycurve PolycurveToSpeckle(AcadDB.Polyline polyline) // AC polylines are polycurves with linear or arc segments { var polycurve = new Polycurve(units: ModelUnits) { closed = polyline.Closed }; // extract segments var segments = new List <ICurve>(); for (int i = 0; i < polyline.NumberOfVertices; i++) { SegmentType type = polyline.GetSegmentType(i); switch (type) { case SegmentType.Line: segments.Add(LineToSpeckle(polyline.GetLineSegmentAt(i))); break; case SegmentType.Arc: segments.Add(ArcToSpeckle(polyline.GetArcSegmentAt(i))); break; } } polycurve.segments = segments; polycurve.length = polyline.Length; polycurve.bbox = BoxToSpeckle(polyline.GeometricExtents, true); return(polycurve); }
// featurelines public Polycurve FeatureLineToSpeckle(CivilDB.FeatureLine featureLine) { var polycurve = new Polycurve() { closed = featureLine.Closed }; // extract segment curves var segments = new List <ICurve>(); var exploded = new DBObjectCollection(); featureLine.Explode(exploded); for (int i = 0; i < exploded.Count; i++) { segments.Add((ICurve)ConvertToSpeckle(exploded[i])); } polycurve.segments = segments; return(polycurve); }
public AcadDB.Polyline PolycurveToNativeDB(Polycurve polycurve) //polylines can only support curve segments of type circular arc { AcadDB.Polyline polyline = new AcadDB.Polyline() { Closed = polycurve.closed }; var plane = new Autodesk.AutoCAD.Geometry.Plane(Point3d.Origin, Vector3d.ZAxis.TransformBy(Doc.Editor.CurrentUserCoordinateSystem)); // TODO: check this // add all vertices for (int i = 0; i < polycurve.segments.Count; i++) { var segment = polycurve.segments[i]; switch (segment) { case Line o: polyline.AddVertexAt(i, PointToNative(o.start).Convert2d(plane), 0, 0, 0); if (!polycurve.closed && i == polycurve.segments.Count - 1) { polyline.AddVertexAt(i + 1, PointToNative(o.end).Convert2d(plane), 0, 0, 0); } break; case Arc o: var bulge = Math.Tan((double)(o.endAngle - o.startAngle) / 4); // bulge polyline.AddVertexAt(i, PointToNative(o.startPoint).Convert2d(plane), bulge, 0, 0); if (!polycurve.closed && i == polycurve.segments.Count - 1) { polyline.AddVertexAt(i + 1, PointToNative(o.endPoint).Convert2d(plane), 0, 0, 0); } break; default: throw new Speckle.Core.Logging.SpeckleException("Polycurve segment is not a line or arc!"); } } return(polyline); }
public Polycurve PolycurveToSpeckle(Polyline2d polyline) // AC polyline2d can have linear, circlular, or elliptical segments { var polycurve = new Polycurve(units: ModelUnits) { closed = polyline.Closed }; // extract segment curves var segments = new List <ICurve>(); var exploded = new DBObjectCollection(); polyline.Explode(exploded); for (int i = 0; i < exploded.Count; i++) { segments.Add((ICurve)ConvertToSpeckle(exploded[i])); } polycurve.segments = segments; polycurve.length = polyline.Length; polycurve.bbox = BoxToSpeckle(polyline.GeometricExtents, true); return(polycurve); }
public Alignment AlignmentToSpeckle(CivilDB.Alignment alignment) { var _alignment = new Alignment(); // get the alignment subentity curves List <ICurve> curves = new List <ICurve>(); var stations = new List <double>(); for (int i = 0; i < alignment.Entities.Count; i++) { var entity = alignment.Entities.GetEntityByOrder(i); var polycurve = new Polycurve(units: ModelUnits, applicationId: entity.EntityId.ToString()); var segments = new List <ICurve>(); double length = 0; for (int j = 0; j < entity.SubEntityCount; j++) { CivilDB.AlignmentSubEntity subEntity = entity[j]; ICurve segment = null; switch (subEntity.SubEntityType) { case CivilDB.AlignmentSubEntityType.Arc: var arc = subEntity as CivilDB.AlignmentSubEntityArc; segment = AlignmentArcToSpeckle(arc); break; case CivilDB.AlignmentSubEntityType.Line: var line = subEntity as CivilDB.AlignmentSubEntityLine; segment = AlignmentLineToSpeckle(line); break; case CivilDB.AlignmentSubEntityType.Spiral: var spiral = subEntity as CivilDB.AlignmentSubEntitySpiral; segment = AlignmentSpiralToSpeckle(spiral, alignment); break; } if (segment != null) { length += subEntity.Length; segments.Add(segment); } } if (segments.Count == 1) { curves.Add(segments[0]); } else { polycurve.segments = segments; polycurve.length = length; // add additional props like entity type polycurve["alignmentType"] = entity.EntityType.ToString(); curves.Add(polycurve); } } // get display poly var poly = alignment.BaseCurve as Autodesk.AutoCAD.DatabaseServices.Polyline; using (Polyline2d poly2d = poly.ConvertTo(false)) { _alignment.displayValue = CurveToSpeckle(poly2d.Spline.ToPolyline()) as Polyline; } _alignment.curves = curves; if (alignment.DisplayName != null) { _alignment.name = alignment.DisplayName; } if (alignment.StartingStation != null) { _alignment.startStation = alignment.StartingStation; } if (alignment.EndingStation != null) { _alignment.endStation = alignment.EndingStation; } // handle station equations var equations = new List <double>(); var directions = new List <bool>(); foreach (var stationEquation in alignment.StationEquations) { equations.AddRange(new List <double> { stationEquation.RawStationBack, stationEquation.StationBack, stationEquation.StationAhead }); bool equationIncreasing = (stationEquation.EquationType.Equals(CivilDB.StationEquationType.Increasing)) ? true : false; directions.Add(equationIncreasing); } _alignment.stationEquations = equations; _alignment.stationEquationDirections = directions; _alignment.units = ModelUnits; // add civil3d props if they exist if (alignment.SiteName != null) { _alignment["site"] = alignment.SiteName; } if (alignment.StyleName != null) { _alignment["style"] = alignment.StyleName; } return(_alignment); }
public CivilDB.FeatureLine FeatureLineToNative(Polycurve polycurve) { return(null); }