public static Point3dCollection Get3dPath(Polyline polyline, ACD.Profile profile) { Point3d point; double interval = 1.0; var points = new Point3dCollection(); var station = -interval; double elevation; do { station += interval; if (station > polyline.Length) { station = polyline.Length; } elevation = profile.ElevationAt(station); point = polyline.GetPointAtDist(station); point = new Point3d(point.X, point.Y, elevation); points.Add(point); } while (station < polyline.Length); return(points); }
private void CreateProfil(double station1, double station2) { using (Transaction tr = db.TransactionManager.StartTransaction()) { // gets the existing profile Autodesk.Civil.DatabaseServices.Profile profile = profiles.SingleOrDefault(x => x.Name == profileName); ProfilePVICollection pPviCollExist = profile.PVIs; ObjectId labelSetId = CivilApplication.ActiveDocument.Styles.LabelSetStyles.ProfileLabelSetStyles["_No Labels"]; ObjectId profileStyleId = CivilApplication.ActiveDocument.Styles.ProfileStyles["Design Profile"]; ObjectId oProfileId = Autodesk.Civil.DatabaseServices.Profile.CreateByLayout("Copied profile", newAlig.ObjectId, newAlig.LayerId, profileStyleId, labelSetId); Autodesk.Civil.DatabaseServices.Profile newProfile = tr.GetObject(oProfileId, OpenMode.ForWrite) as Autodesk.Civil.DatabaseServices.Profile; if (pPviCollExist.Count <= 3) { Point2d point1 = new Point2d(station1, profile.ElevationAt(station1)); Point2d point2 = new Point2d(station2, profile.ElevationAt(station2)); CreateProfileFromEntities(profile.Entities[0], profile, newProfile, point1, point2); tr.Commit(); } else { // finding values near our start station for copied alignment ProfilePVI pPviExistStart = pPviCollExist.GetPVIAt(station1, profile.ElevationAt(station1)); ProfilePVI pPviExistEnd = pPviCollExist.GetPVIAt(station2, profile.ElevationAt(station2)); ProfileEntity pEntitiyAfter = profile.Entities.EntityAtId(pPviExistStart.EntityAfter); Point2d pviEndPoint = new Point2d(pEntitiyAfter.StartStation, pEntitiyAfter.StartElevation); ProfileEntity pEntitiyBefore = profile.Entities.EntityAtId(pPviExistEnd.EntityBefore); Point2d pviStartPoint = new Point2d(pEntitiyBefore.EndStation, pEntitiyBefore.EndElevation); ProfileEntity pStartEntity = pPviExistStart.VerticalCurve; ProfileEntity pEndEntity = pPviExistEnd.VerticalCurve; ProfileEntityCollection pEntities = profile.Entities; uint index = pEntities.FirstEntity; Point2d firstPoint = new Point2d(station1, profile.ElevationAt(station1)); CreateProfileFromEntities(pStartEntity, profile, newProfile, firstPoint, pviEndPoint); int counter = 0; try { while (true) { ProfileEntity pEntity = pEntities.EntityAtId(index); if (pEntity.StartStation >= station1 && pEntity.EndStation <= station2) { Point2d StartPoint = new Point2d(pEntity.StartStation, pEntity.StartElevation); Point2d EndPoint = new Point2d(pEntity.EndStation, pEntity.EndElevation); CreateProfileFromEntities(pEntity, profile, newProfile, StartPoint, EndPoint); counter++; } if (pEntity.StartStation <= station1 && pEntity.EndStation >= station2) { oneEntity = pEntity; } index = pEntity.EntityAfter; } } catch { if (counter == 0) { Point2d point1 = new Point2d(station1, profile.ElevationAt(station1)); Point2d point2 = new Point2d(station2, profile.ElevationAt(station2)); CreateProfileFromEntities(oneEntity, profile, newProfile, point1, point2); } else { Point2d endPoint = new Point2d(station2, profile.ElevationAt(station2)); CreateProfileFromEntities(pEndEntity, profile, newProfile, pviStartPoint, endPoint); } } tr.Commit(); } } }