This works fine if my alignment starts at 0+00.. but throws an error when I change the alignments start station to 1+00 or anything else. Any idea why, and hhow I can correct it?
myalign.PointLocation(newdist, 0, 0.0001, ref xValue, ref yValue, ref bearing);
Solved! Go to Solution.
Solved by Jeff_M. Go to Solution.
How are you obtaining the newdist variable, Brian? If this is a distance along the alignment, and the distance is less than the start station, it will fail.
May help to see more code and a sample data set. I use this method a lot in my code and have never seen a problem.
Thanks Jeff! Don't really have anything was just doing a simple while loop to list the station coordinates.
Do you have a working sample you can post?
Here ya go, Brian. I create a 550' long alignment from a polyline, set the ReferenceStation to 20+00, then run a loop at 100' increments to get the location of the station.
[CommandMethod("TestAlignStations")] public void testalignstations() { Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Editor ed = doc.Editor; CivilDocument civdoc = CivilApplication.ActiveDocument; using (Transaction tr = db.TransactionManager.StartTransaction()) { Polyline pline = new Polyline(2); pline.AddVertexAt(0, new Point2d(0, 0), 0, 0, 0); pline.AddVertexAt(1, new Point2d(0, 550), 0, 0, 0); BlockTable bt = (BlockTable)db.BlockTableId.GetObject(OpenMode.ForRead); BlockTableRecord btr = (BlockTableRecord)bt[BlockTableRecord.ModelSpace].GetObject(OpenMode.ForWrite); btr.AppendEntity(pline); tr.AddNewlyCreatedDBObject(pline, true); ObjectId layerId = db.Clayer; ObjectId siteId = ObjectId.Null; ObjectId alignStyle = civdoc.Styles.AlignmentStyles["Standard"]; ObjectId alignStyleSet = civdoc.Styles.LabelSetStyles.AlignmentLabelSetStyles["Standard"]; PolylineOptions pOpts = new PolylineOptions(); pOpts.AddCurvesBetweenTangents = false; pOpts.EraseExistingEntities = true; pOpts.PlineId = pline.ObjectId; Alignment align = (Alignment)Alignment.Create(civdoc, pOpts, "TestAlignment", siteId, layerId, alignStyle, alignStyleSet).GetObject(OpenMode.ForWrite); align.ReferencePointStation = 2000; for (double i = align.StartingStation; i < align.EndingStation; i += 100) { double n = 0, e = 0; align.PointLocation(i, 0, ref n, ref e); ed.WriteMessage("\nStation {0} is located at {1}, {2}", align.GetStationStringWithEquations(i), n.ToString("F2"), e.ToString("F2")); } tr.Commit(); } }
haha...hate how stupid you make me feel sometimes jeff lol... I was trying to make my routine walk through distances by adding 50 from zero until I got to or above the start station hahaha...have no idea why I didn't just set it to the starting station... i need a vacation my brain is toast