[ORD 2020 R2] Get profile elevation at station?

One of the most common questions that I get is "what's the profile elevation at this station".

I haven't found the "magic bullet" tool in ORD to find this information. If there is no built-in tool to answer this question directly, I may need to build one. It doesn't help that I get to learn a new programming language (all I know is VBA, which is no longer supported).

I don't see any explicit methods or properties for this query. Does anyone have a suggestion where I might look, or a code snippet to give me a direction? Are there any particular functions that would be helpful?

Thank you.

Parents
  • Here are some code snippets. I may have went overboard on the comments. Hope it helps.

    // A couple of namespaces you'll need at the top of your class 
    //  using Bentley.CifNET.GeometryModel.SDK;
    //  using Bentley.CifNET.LinearGeometry;
    
    // Assuming you have an object reference to your profile;
    //  I'll use 'myProfile', which is a type of Bentley.CifNET.GeometryModel.SDK.Profile
    // <Insert whatever code you need to get your profile>
    
    // A variable with your station in meters;
    double getElevStationMeters = StationMaster * 0.3048; // 731.52; // i.e. Sta 24+00.00
    
    // Get a linearpoint object at the beginning of the vertical alignment
    LinearPoint profileStartPoint = myProfile.ProfileGeometry.StartPoint;
    
    // Oddly, the X-value of profileStartPoint is the distance from the
    //  beginning of the horizontal to the beginning of the vertical
    //  i.e. How far along the horizontal until your vertical begins
    double distBegHorizToBegVert = profileStartPoint.Coordinates.X;
    
    // So, we still need to know what station the horiz starts at.
    //  And, be careful because if the alignment has no stationing, the 
    //  myProfile.Alignment.Stationing will be null and crash.
    // The line below will default to station 0.0 if Stationing is null.
    double horizStartPoint = myProfile.Alignment.Stationing?.StartStation ?? 0.0;
    
    // Now calculate the begin station of the profile
    double vertStaBegMeters = horizStartPoint + distBegHorizToBegVert;
    
    // Finally, calculate the distance from beginning horiz to our station point
    double distAlongMeters = getElevStationMeters - vertStaBegMeters;
    
    // ORD can calculate the profile elevation at the point your interested in using
    //  GetPointAtDistanceOffset(distance, offset)
    //    distance is the metric distance from the beginning station of the profile
    //    offset is the vertical amount above/below the profile; typically you leave this
    //    at zero to get the pgl elev.
    // Get a linear point from ORD at the distance along
    LinearPoint elev = myProfile.ProfileGeometry.GetPointAtDistanceOffset(distAlongMeters, 0);
    
    // The actual elevation is in the Y-coordinate of the linearpoint
    double elevMeters = elev.Coordinates.Y;
    
    // FYI: You can get a couple other values from the linearpoint
    double distBegHorizToOurStation = elev.Coordinates.X;
    double pglGradeAtStation = elev.TangentDirection;
    
    // Be sure to convert your values back from Metric to Master units

  • Oooh! I can't wait to take a good look at this. Thank you!

    MaryB

    Power GeoPak 08.11.09.918
    Power InRoads 08.11.09.918
    OpenRoads Designer 2021 R2

        

Reply Children
  • Leaving this here for future use:

    I'm going to suggest not using GetPointAtDistanceOffset as i noticed some slight discrepancies from my own calculations. Instead, I switched to GetPointAtX(distAlongFromStartHorizMeters).

    So, more like so:

    double stationMeters = dh.ConvertMasterToMeter(stationMaster);
    double horizStartStation = profile.Alignment.Stationing?.StartStation ?? 0.0;
    double distAlongFromStartHorizMeters = stationMeters - horizStartStation;
    LinearPoint elevPt = profile.ProfileGeometry.GetPointAtX(distAlongFromStartHorizMeters);
    double elevMeters = elevPt.Coordinates.Y;
    elevationMaster =  dh.ConvertMeterToMaster(elevMeters);