I'm having an issue in attempting to get the slope at a station
Executing this line of code
nsLeftIn_End = mySuperStn.GetSlope(Autodesk.Civil.Land.Supereleva
in the function below throws an execption:
Operation is not valid due to the current state of the object.
I've stripped down the function to show where the error is happening. I verifiied that the execption is still thrown in this version of the function.
I can't for the life of me figure out what is wrong with the state of the object that won't allow for getting the slope value.
Any suggestions appreciated.
Function ModifySuper(ByRef myAlg As Alignment) As Boolean Dim nsLeftIn_End As Double Dim nsLeftOut_End As Double Dim nsRightIn_End As Double Dim nsRightOut_End As Double Dim mySuperCol As SuperelevationCriticalStationCollection Dim mySuperStn As SuperelevationCriticalStation ModifySuper = False Try If IsNothing(myAlg) Then MsgBox("Cannot locate alignment in ModifySuper ", vbExclamation) Exit Function End If mySuperCol = myAlg.SuperelevationCriticalStations For Each mySuperStn In mySuperCol Select Case mySuperStn.StationType Case Autodesk.Civil.Land.SuperelevationCriticalStationT
ype.BeginAlignment Case Autodesk.Civil.Land.SuperelevationCriticalStationT ype.EndAlignment Case Autodesk.Civil.Land.SuperelevationCriticalStationT ype.BeginNormalCrown Case Autodesk.Civil.Land.SuperelevationCriticalStationT ype.EndNormalCrown Case Autodesk.Civil.Land.SuperelevationCriticalStationT ype.EndNormalShoulder Try nsLeftIn_End = mySuperStn.GetSlope(Autodesk.Civil.Land.Supereleva tionCrossSegmentType.LeftInShoulderCrossSlope) nsLeftOut_End = mySuperStn.GetSlope(Autodesk.Civil.Land.Supereleva tionCrossSegmentType.LeftOutShoulderCrossSlope) nsRightIn_End = mySuperStn.GetSlope(Autodesk.Civil.Land.Supereleva tionCrossSegmentType.RightInShoulderCrossSlope) nsRightOut_End = mySuperStn.GetSlope(Autodesk.Civil.Land.Supereleva tionCrossSegmentType.RightOutShoulderCrossSlope) Catch ex As Exception MsgBox("Exception: " & ex.Message) End Try Case Autodesk.Civil.Land.SuperelevationCriticalStationT ype.LevelCrown End Select Next ModifySuper = True Catch ex As Exception MsgBox("Execption: " & ex.Message) End Try End Function
Did you check in the UI dialog if there is a valid value set for LeftInShoulderCrossSlope at that station?
You can take a look at the following Blog post and check the screenshot I used there to understand which UI window I am referring here.
This problem appears when exists two default criticalstation that you can´t delete.
These criticalstations are the start alignment and the end alignment.
|Thrown when index is out of the collecton range.|
|System.InvalidOperationException||Thrown when the criticalStationType is BeingAlignment or EndAlignment.|
And this exception can be too:
You have to "Lock" the database before write it.
For Each mySuperStn In mySuperCol If mySuperStn.Station = myAlg.StartingStation OrElse mySuperStn.Station = myAlg.EndingStation Then //nothing Else Select case.... End If
This is the solution:
You have to write code of each Segment Type using "Try", because maybe doesn´t exist that segment type (however, left outside lane and right outside lane always exist). You can use boolean variables.(In catch method bool variable=false)
And you have to know if a Segment type exist.
I had the same problem.
I think that It should exist in the API (superelevationCriticalStation Class) the booleans properties
Excuse me because I have remixed C# code and Visual Basic.
Try nsLeftIn_End = mySuperStn.GetSlope(Autodesk.Civil.Land.Supereleva
This is the exactly same sample.
Is this issue resolved through this link ?
Do you need any further help ?
No. Thank you.
I was only adding more information.
Access a broad range of knowledge to help get the most out of your products and services.