internal AlignmentMultipleSegments(C3dDb.AlignmentMultipleSegments mseg) : base(mseg) { for (int i = 0; i < mseg.SubEntityCount; i++) { C3dDb.AlignmentSubEntity curve = mseg[i]; if (curve is C3dDb.AlignmentSubEntityLine line) { SubEntities.Add(new AlignmentLine(line)); } else if (curve is C3dDb.AlignmentSubEntityArc arc) { SubEntities.Add(new AlignmentArc(arc)); } } }
internal AlignmentNotLinearCurve(C3dDb.AlignmentSubEntity subEntity) : base(subEntity) { SetProps(subEntity); }
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); }