[c#] convert Bentley.SurveyNET.SDK.SurveyPoint to Bentley.GeometryNET.DPoint3d.

i have a surveypoint and an alignment. i want to get the station and offset of that point about my alignment.

i want to use .LinearGeometry.ProjectPointOnPerpendicular(point);

but i cant pass in a survey point, it has to be a dpoint3D

any ideas.

Parents
  • John,

    We do have a command that will report the Station Offset Elevation and Feature of a Survey Point.  It is GEOMETRY REPORT STATIONOFFSETELEVATIONFEATURE

    If you want to do it in code you can do something like the following:  SurveyPoint has properties exposed to get North, East, Elevation 

    DPoint3d MyPoint  = new DPoint3d(sirveyPoint.Easting, SurveyPoint.Northing, SurveyPoint.Elevation);

  • Chris,

    when i tried that i was getting some crazy results..but comparing the point values to what it shows in running coordinates when snapped to the point i realized that the numbers were off by a factor of 12000. so i divided the northing and easting by 12000, this is my resolution that is set on the file, goto Design File Settings > Working units > Resolution. but still got crazy results.

    i then looking at my alignment variable and looked at the starting point coordinates and noticed that they were different from what running coordinates gave me when snapping to the start of my alignment. i figured out it was a off by a factor of  3.2804 which is taking it to meters. so i then converted my northing and easting to meters and got a result that made a little more sense but still not right. 

    i had to then take the offset value and convert it from meters to feet. but to get the station value i did not have to convert anything.seems like the settings were handling that.

    here is some sample code.

    the station stuff i did use this post for help

    https://communities.bentley.com/products/programming/civil_programming/f/civil_programming_forum/168983/lineargeometry-projectpointonperpendicular

    public static bool getStationOffset(Bentley.SurveyNET.SDK.SurveyPoint SP, Bentley.CifNET.GeometryModel.SDK.Alignment Align)
            {
    
                //get meter to feet conversion (settings.DefaultUnitsToMeters)
                StationFormatSettings settings = StationFormatSettings.GetStationFormatSettingsForModel(Bentley.MstnPlatformNET.Session.Instance.GetActiveDgnModel());
                settings.StationFormat = 2;
                //get resolution of active file
                double UORs = Bentley.MstnPlatformNET.Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
    
                
                Bentley.GeometryNET.DPoint3d point =  new Bentley.GeometryNET.DPoint3d((SP.Easting/ UORs) * settings.DefaultUnitsToMeters, (SP.Northing/ UORs) * settings.DefaultUnitsToMeters, (SP.Elevation/ UORs) * settings.DefaultUnitsToMeters);
                
                LinearPoint MonumentLoc = Align.LinearGeometry.ProjectPointOnPerpendicular(point);
                double offset = MonumentLoc.Offset * (1/settings.DefaultUnitsToMeters);
                // Get numerical station
                string strStation = "";
                double dblStation = MonumentLoc.DistanceOnExtension + MonumentLoc.DistanceAlong;
    
                // Format it
                StationingFormatter sformatter = new StationingFormatter(Align);
                sformatter.FormatStation(ref strStation, dblStation, settings);
                ....
            }

    thanks...at first i thought i couldnt use the northing and easting values because i was getting such crazy results. but your post telling me to use them got me back to digging around a little and figured it out.

    thanks

    JD

    Answer Verified By: John Drsek 

Reply
  • Chris,

    when i tried that i was getting some crazy results..but comparing the point values to what it shows in running coordinates when snapped to the point i realized that the numbers were off by a factor of 12000. so i divided the northing and easting by 12000, this is my resolution that is set on the file, goto Design File Settings > Working units > Resolution. but still got crazy results.

    i then looking at my alignment variable and looked at the starting point coordinates and noticed that they were different from what running coordinates gave me when snapping to the start of my alignment. i figured out it was a off by a factor of  3.2804 which is taking it to meters. so i then converted my northing and easting to meters and got a result that made a little more sense but still not right. 

    i had to then take the offset value and convert it from meters to feet. but to get the station value i did not have to convert anything.seems like the settings were handling that.

    here is some sample code.

    the station stuff i did use this post for help

    https://communities.bentley.com/products/programming/civil_programming/f/civil_programming_forum/168983/lineargeometry-projectpointonperpendicular

    public static bool getStationOffset(Bentley.SurveyNET.SDK.SurveyPoint SP, Bentley.CifNET.GeometryModel.SDK.Alignment Align)
            {
    
                //get meter to feet conversion (settings.DefaultUnitsToMeters)
                StationFormatSettings settings = StationFormatSettings.GetStationFormatSettingsForModel(Bentley.MstnPlatformNET.Session.Instance.GetActiveDgnModel());
                settings.StationFormat = 2;
                //get resolution of active file
                double UORs = Bentley.MstnPlatformNET.Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
    
                
                Bentley.GeometryNET.DPoint3d point =  new Bentley.GeometryNET.DPoint3d((SP.Easting/ UORs) * settings.DefaultUnitsToMeters, (SP.Northing/ UORs) * settings.DefaultUnitsToMeters, (SP.Elevation/ UORs) * settings.DefaultUnitsToMeters);
                
                LinearPoint MonumentLoc = Align.LinearGeometry.ProjectPointOnPerpendicular(point);
                double offset = MonumentLoc.Offset * (1/settings.DefaultUnitsToMeters);
                // Get numerical station
                string strStation = "";
                double dblStation = MonumentLoc.DistanceOnExtension + MonumentLoc.DistanceAlong;
    
                // Format it
                StationingFormatter sformatter = new StationingFormatter(Align);
                sformatter.FormatStation(ref strStation, dblStation, settings);
                ....
            }

    thanks...at first i thought i couldnt use the northing and easting values because i was getting such crazy results. but your post telling me to use them got me back to digging around a little and figured it out.

    thanks

    JD

    Answer Verified By: John Drsek 

Children
No Data