private static void AddSQX(ref Profile myPr, ref SRBA.SQX kitty, ref Editor ed) { Point2d St = new Point2d(kitty.BPDList[0].PK, kitty.BPDList[0].H), Ed; Point2d A = new Point2d(), B = new Point2d(), C = new Point2d(); SRBA.BPD preBPD = new SRBA.BPD(), curBPD = new SRBA.BPD(), nextBPD = new SRBA.BPD(); if (kitty.BPDList.Count <= 2) { curBPD = kitty.BPDList[0]; nextBPD = kitty.BPDList[1]; B = new Point2d(curBPD.PK, curBPD.H); C = new Point2d(nextBPD.PK, nextBPD.H); myPr.Entities.AddFixedTangent(B, C); return; } for (int i = 0; i < kitty.BPDList.Count; i++) { curBPD = kitty.BPDList[i]; if (i != 0) { Ed = new Point2d(curBPD.PK, curBPD.H); myPr.Entities.AddFixedTangent(St, Ed); St = Ed; } } for (int i = 1; i < kitty.BPDList.Count - 2; i++) { curBPD = kitty.BPDList[i]; if (curBPD.R == 0) { continue; } ProfileTangent ptA = (ProfileTangent)myPr.Entities[i]; ProfileTangent ptB = (ProfileTangent)myPr.Entities[i + 1]; VerticalCurveType ct = ptA.Grade < ptB.Grade ? VerticalCurveType.Sag : VerticalCurveType.Crest; double dr = 0.01; double RR = curBPD.R; while (true) { try { myPr.Entities.AddFreeSymmetricParabolaByRadius((uint)i, (uint)(i + 1), ct, RR); break; } catch { RR = RR - dr; continue; } } } //oProfile.Entities.AddFreeSymmetricParabolaByLength(oTangent1.EntityId, oTangent2.EntityId, VerticalCurveType.Sag, 900.1, true); }
private void CreateProfileFromEntities(ProfileEntity pentity, Autodesk.Civil.DatabaseServices.Profile Eprofile, Autodesk.Civil.DatabaseServices.Profile Nprofile, Point2d startPoint, Point2d endPoint) { using (Transaction tr = db.TransactionManager.StartTransaction()) { switch (pentity.EntityType) { case ProfileEntityType.Tangent: ProfileTangent pTangent = Nprofile.Entities.AddFixedTangent(startPoint, endPoint); break; case ProfileEntityType.Circular: ProfileCircular pCircular = pentity as ProfileCircular; ProfilePVI pPVI = Eprofile.PVIs.GetPVIAt(pCircular.PVIStation, pCircular.PVIElevation); double circleLength = pCircular.Length; ProfileCircular pCircularNew = Nprofile.Entities.AddFreeCircularCurveByPVIAndLength(pPVI, circleLength); break; case ProfileEntityType.ParabolaSymmetric: ProfileParabolaSymmetric pParabolaSymetric = pentity as ProfileParabolaSymmetric; double parabolaRadius = pParabolaSymetric.Radius; VerticalCurveType vcType = pParabolaSymetric.CurveType; ProfileParabolaSymmetric pParabolaSymetricNew = Nprofile.Entities.AddFixedSymmetricParabolaByTwoPointsAndRadius(startPoint, endPoint, vcType, parabolaRadius); break; case ProfileEntityType.ParabolaAsymmetric: ProfileParabolaAsymmetric pParabolaAsymmetric = pentity as ProfileParabolaAsymmetric; ProfilePVI paPVI = Eprofile.PVIs.GetPVIAt(pParabolaAsymmetric.PVIStation, pParabolaAsymmetric.PVIElevation); double pLength1 = pParabolaAsymmetric.AsymmetricLength1; double pLength2 = pParabolaAsymmetric.AsymmetricLength2; ProfileParabolaAsymmetric pParabolaAsymmetricNew = Nprofile.Entities.AddFreeAsymmetricParabolaByPVIAndLengths(paPVI, pLength1, pLength2); break; case ProfileEntityType.None: ProfileTangent nTangent = Nprofile.Entities.AddFixedTangent(startPoint, endPoint); break; } tr.Commit(); } }
// definira visinsko vođenje objekta // postoji mogućnost poboljšanja public Profile IzradaProfila(Alignment aligIn) { if (aligIn != null) { string ime = "Niveleta okomitog pera " + brojPera.ToString(); using (Transaction ts = AcAp.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction()) { Alignment alig = aligIn; // postavke profila ObjectId layerProfila = alig.LayerId; ObjectId styleProfila = civDoc.Styles.ProfileStyles["Basic"]; ObjectId labelSetId = civDoc.Styles.LabelSetStyles.ProfileLabelSetStyles["_No Labels"]; // stvaranje praznog profila ObjectId ProfilPeraId = Profile.CreateByLayout(ime, alig.Id, layerProfila, styleProfila, labelSetId); // dodavanje elemenata u profil Profile ProfilPera = ts.GetObject(ProfilPeraId, OpenMode.ForRead) as Profile; // definiranje pointova Point3d prviPoint = TockaNaStacionazi(KodUzglavlje); Point3d drugiPoint = TockaNaStacionazi(KodZaglavlje); Point3d _prviPoint = new Point3d(prviPoint.X, prviPoint.Y, 0); Point3d _drugiPoint = new Point3d(drugiPoint.X, drugiPoint.Y, 0); Point3d GlavaPera = TockaNaStacionazi(KodGlave); // određivanje duljine iz polyline-a ObjectId pomocniPolyId = alig.GetPolyline(); Polyline pomocniPoly = ts.GetObject(pomocniPolyId, OpenMode.ForRead) as Polyline; double ukupnaDuljina = pomocniPoly.Length; double pocetnaDuljina = _prviPoint.DistanceTo(_drugiPoint); DuljinaPera = pocetnaDuljina; double duljinaLuka = ukupnaDuljina - 2 * pocetnaDuljina; // izrada pointova i dobivanje profila (mislim da se može brže) // dodatno istražiti // for petaljom ? Point2d profilePoint1 = new Point2d(alig.StartingStation, prviPoint.Z); Point2d profilePoint2 = new Point2d(alig.StartingStation + DuljinaPera, drugiPoint.Z); ProfileTangent Tangenta1 = ProfilPera.Entities.AddFixedTangent(profilePoint1, profilePoint2); Point2d profilePoint3 = new Point2d(Tangenta1.EndStation, Tangenta1.EndElevation); Point2d profilePoint4 = new Point2d(Tangenta1.EndStation + duljinaLuka / 2, GlavaPera.Z); ProfileTangent Tangenta2 = ProfilPera.Entities.AddFixedTangent(profilePoint3, profilePoint4); Point2d profilePoint5 = new Point2d(Tangenta2.EndStation, Tangenta2.EndElevation); Point2d profilePoint6 = new Point2d(Tangenta2.EndStation + duljinaLuka / 2, drugiPoint.Z); ProfileTangent Tangenta3 = ProfilPera.Entities.AddFixedTangent(profilePoint5, profilePoint6); Point2d profilePoint7 = new Point2d(Tangenta3.EndStation, Tangenta3.EndElevation); Point2d profilePoint8 = new Point2d(alig.EndingStation, prviPoint.Z); ProfileTangent Tangenta4 = ProfilPera.Entities.AddFixedTangent(profilePoint7, profilePoint8); ts.Commit(); return(ProfilPera); } } else { return(null); } }