The API provided by Civil3d, which is the method provided by the Profiles profile class---Public double elevationat, makes it easy to get the elevation value at a station of a profile object. The elevation values can then be obtained in batches. The code for implementation is given below.
First write an extension method for the Profiles profile class (the extension method is quite useful) to return the elevation value at a station.
1 /// <summary>2 ///gets the elevation value in the profile given the station value, April 21, 20183 ///if the given station is within the profile range, the corresponding elevation value is returned, otherwise null is returned4 /// </summary>5 /// <param name= "Profile" ></param>6 /// <param name= "station" ></param>7 /// <returns></returns>8 Public Static Double? Getelevationfromprofile ( ThisProfile profile,DoubleStation )9 {Ten Double? elevation =NULL;//define a nullable type of data One varStartstation =Profile . startingstation; A varEndstation =Profile . endingstation; - if(Station >= startstation && station <= endstation)//determine the station number within the longitudinal section of the station range - { theelevation =Profile . Elevationat (station); - } - - returnelevation; +}
You can then get the elevation data for the station by calling the method above.
1[Commandmethod ("Getelvfromprofile")]2 Public Static voidGetelvfromprofile ()3 {4Document doc =AcadApp.DocumentManager.MdiActiveDocument;5Database db =Doc. Database;6Editor ed =Doc. Editor;7Civildocument Civildoc =civilapplication.activedocument;8 varopt =NewPromptentityoptions ("\ n Please pick up a profile object");9Opt. Setrejectmessage ("\ n Object must be a profile object");TenOpt. Addallowedclass (typeof(profile),false); One varres =ed. GetEntity (opt); A if(Res. Status! =Promptstatus.ok) - { -Ed. Writemessage ("you've canceled your choice."); the return; - } - varDoubleresult = ed. GetDouble ("\ n Please enter a station number"); - DoubleStation =Doubleresult.value; - using(Documentlock Doclock =Doc. LockDocument ()) + using(Transaction trans =db. Transactionmanager.starttransaction ()) A { atProfile profile = trans. GetObject (Res. ObjectId, Openmode.forread) asprofile;//getting profile objects - Double? elevation =Profile . Getelevationfromprofile (station);//Call the extension method to get the elevation value - //ed. Writemessage (profile. Getelevationfromprofile (station). ToString ()); -Ed. Writemessage (elevation?. ToString ()); - } -}
If you want to get an elevation in bulk, you can do it with a loop.
A given station gets the elevation values in the profile (C # for Civil3d)