Need an example of how to use StationOffset() in civil3d. I used point3d to get a var x and var y.... need to know how to select my alignment and report the station/offset for that coordinate. Any help / examples would be most appreciated.
Thanks!
Diggin through Sinpac Free Source...maybe I'll figure out
A word of caution. While the SincpacC3D source code may be of some benefit, it was originally written based on the C3D2007 API's. A lot has changed since then, specifically the .NET API's were born, so those examples do not have anything that deals with these newer API's.
And some sample code using the .NET API:
[CommandMethod("AlignmentTest")] public void alignmenttest() { Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; ObjectId alignId = SelectAlignment(doc.Editor); if (alignId == ObjectId.Null) return; using (Transaction tr = db.TransactionManager.StartTransaction()) { Alignment align = (Alignment)alignId.GetObject(OpenMode.ForRead); double station = Double.NaN; double offset = Double.NaN; PromptPointOptions ptOpts = new PromptPointOptions("\nPick point for Station/Offset:"); ptOpts.AllowNone = true; ptOpts.AllowArbitraryInput = false; PromptPointResult ptRes = doc.Editor.GetPoint(ptOpts); while (ptRes.Status == PromptStatus.OK) { try { align.StationOffset(ptRes.Value.X, ptRes.Value.Y, ref station, ref offset); doc.Editor.WriteMessage("\nThe station and offset at the picked point is: {0}, {1}", align.GetStationStringWithEquations(station), offset.ToString("F2")); } catch (Autodesk.Civil.CivilException ex) { string msg = ex.Message; } ptRes = doc.Editor.GetPoint(ptOpts); } } } private ObjectId SelectAlignment(Editor ed) { ObjectId result = ObjectId.Null; PromptEntityOptions entOpts = new PromptEntityOptions("\nSelect alignment: "); entOpts.SetRejectMessage("...not an Alignment, try again!:"); entOpts.AddAllowedClass(typeof(Alignment), true); PromptEntityResult entRes = ed.GetEntity(entOpts); if (entRes.Status == PromptStatus.OK) result = entRes.ObjectId; return result; }
Thanks Jeff! I was able to finally put something together real late last night... but your code shows me where I worked way too hard lol.... much appreciated!