Tuesday, January 25, 2011

Find Profile View Grid Start Point

If you want to find the Profile View Grid Start Point, you may end up not getting the expected results you wanted. When you use the FindXYAtStationAndElevation method of the profile view and use the StationStart and ElevationMin properties you may get an erroneous report if you are the profile view is set to Automatic. This is because the profile view uses padding in the style that is different then what is shown. An easy way around this is to set the elevation range mode to UserSpecified and get the XY value that way. Below is a function I used to test it out. The MessageWriter is something in the Civil3DRemindersPack, so just remove those lines of code if you aren’t building off it.

Public Function GetProfViewOrgin(ByVal ProfViewObjId As ObjectId) As Point2d

Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor
Using trans As Transaction = db.TransactionManager.StartTransaction

Dim profView As ProfileView
= DirectCast(trans.GetObject(ProfViewObjId, OpenMode.ForRead, True), ProfileView)

Dim dX As Double
Dim dY As Double

' Since the FindXY doesn't return what's shown on the screen always, check the

Select Case profView.ElevationRangeMode
Case ElevationRangeType.Automatic
"Automatic StaStart: " & profView.StationStart & " ElevMin: " & profView.ElevationMin)
= ElevationRangeType.UserSpecified
"User Specificed StaStart: " & profView.StationStart & " ElevMin: " & profView.ElevationMin)
profView.FindXYAtStationAndElevation(profView.StationStart, profView.ElevationMin, dX, dY)
' Don't need to set it back since the transaction isn't committed.
Case ElevationRangeType.UserSpecified
profView.FindXYAtStationAndElevation(profView.StationStart, profView.ElevationMin, dX, dY)
End Select

"StaStart: " & profView.StationStart & " ElevMin: " & profView.ElevationMin)
Return New Point2d(dX, dY)

End Using

End Function

No comments:


Blog Widget by LinkWithin