AutoCAD Civil 3D Customization

Reply
Active Contributor
RodWing
Posts: 26
Registered: ‎04-18-2008
Message 1 of 9 (243 Views)

C3D 2012 SuperelevationCriticalStation.GetSlope VB.Net

243 Views, 8 Replies
07-31-2012 09:16 AM

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.SuperelevationCrossSegmentType.LeftInShoulderCrossSlope)

 

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.

Thanks.

 

 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.SuperelevationCriticalStationType.BeginAlignment

                    Case Autodesk.Civil.Land.SuperelevationCriticalStationType.EndAlignment

                    Case Autodesk.Civil.Land.SuperelevationCriticalStationType.BeginNormalCrown

                    Case Autodesk.Civil.Land.SuperelevationCriticalStationType.EndNormalCrown

                    Case Autodesk.Civil.Land.SuperelevationCriticalStationType.EndNormalShoulder
                        Try
                            nsLeftIn_End = mySuperStn.GetSlope(Autodesk.Civil.Land.SuperelevationCrossSegmentType.LeftInShoulderCrossSlope)
                            nsLeftOut_End = mySuperStn.GetSlope(Autodesk.Civil.Land.SuperelevationCrossSegmentType.LeftOutShoulderCrossSlope)
                            nsRightIn_End = mySuperStn.GetSlope(Autodesk.Civil.Land.SuperelevationCrossSegmentType.RightInShoulderCrossSlope)
                            nsRightOut_End = mySuperStn.GetSlope(Autodesk.Civil.Land.SuperelevationCrossSegmentType.RightOutShoulderCrossSlope)

                        Catch ex As Exception
                            MsgBox("Exception: " & ex.Message)
                        End Try

                    Case Autodesk.Civil.Land.SuperelevationCriticalStationType.LevelCrown
                End Select

            Next

            ModifySuper = True

        Catch ex As Exception
            MsgBox("Execption: " & ex.Message)
        End Try
    End Function

 

ADN Support Specialist
Partha.Sarkar
Posts: 543
Registered: ‎06-09-2009
Message 2 of 9 (228 Views)

Re: C3D 2012 SuperelevationCriticalStation.GetSlope VB.Net

08-03-2012 03:50 AM in reply to: RodWing

Hi RodWing,

 

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.

 

http://adndevblog.typepad.com/infrastructure/2012/06/want-to-add-a-superelevationcriticalstation-usi...


Thanks,



Partha Sarkar
Developer Technical Services
Autodesk Developer Network

Valued Mentor
joantopo
Posts: 644
Registered: ‎04-25-2010
Message 3 of 9 (158 Views)

Re: C3D 2012 SuperelevationCriticalStation.GetSlope VB.Net

09-14-2013 10:29 AM in reply to: Partha.Sarkar

This problem appears when exists two default criticalstation that you can´t delete.

These criticalstations are the start alignment and the end alignment.

 

 

Exception:                                                               Condition:

 

System.ArgumentOutOfRangeException

Thrown when index is out of the collecton range.
System.InvalidOperationExceptionThrown when the criticalStationType is BeingAlignment or EndAlignment.
Autocad Civil 3D 2014 +SP1 // Civil 3D 2015
Quad Core Intel i7 3770-cpu 3.40Ghz.
ssd samsung 840 pro 512gb+ssd samsung 840 pro 256 gb+1tb hdd
32gb RAM 1600 Mhz.
nVidia Quadro 2000.
Win 7 Pro 64bit

Valued Mentor
joantopo
Posts: 644
Registered: ‎04-25-2010
Message 4 of 9 (157 Views)

Re: C3D 2012 SuperelevationCriticalStation.GetSlope VB.Net

09-14-2013 10:35 AM in reply to: joantopo

And this exception can be too:

 

http://adndevblog.typepad.com/autocad/2012/05/adding-or-modifying-the-database-from-modeless-dialog-...

 

You have to "Lock" the database before write it.

 

 

Autocad Civil 3D 2014 +SP1 // Civil 3D 2015
Quad Core Intel i7 3770-cpu 3.40Ghz.
ssd samsung 840 pro 512gb+ssd samsung 840 pro 256 gb+1tb hdd
32gb RAM 1600 Mhz.
nVidia Quadro 2000.
Win 7 Pro 64bit

Valued Mentor
joantopo
Posts: 644
Registered: ‎04-25-2010
Message 5 of 9 (149 Views)

Re: C3D 2012 SuperelevationCriticalStation.GetSlope VB.Net

09-14-2013 11:06 AM in reply to: joantopo
For Each mySuperStn In mySuperCol

If mySuperStn.Station = myAlg.StartingStation OrElse mySuperStn.Station = myAlg.EndingStation Then

//nothing 


Else

Select case....

End If

 

Autocad Civil 3D 2014 +SP1 // Civil 3D 2015
Quad Core Intel i7 3770-cpu 3.40Ghz.
ssd samsung 840 pro 512gb+ssd samsung 840 pro 256 gb+1tb hdd
32gb RAM 1600 Mhz.
nVidia Quadro 2000.
Win 7 Pro 64bit

Valued Mentor
joantopo
Posts: 644
Registered: ‎04-25-2010
Message 6 of 9 (129 Views)

Re: C3D 2012 SuperelevationCriticalStation.GetSlope VB.Net

09-16-2013 04:23 AM in reply to: joantopo

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 

IsSegmentTypeLeftInShoulderCrossSlope, IsSegmentTypeLeftinLaneCrossSlope,...

 

Excuse me because I  have remixed  C# code and  Visual Basic.

 

bool LeftInShoulderCrossSl0pe

Try nsLeftIn_End = mySuperStn.GetSlope(Autodesk.Civil.Land.SuperelevationCrossSegmentType.LeftInShoulderCrossSlope)

LeftInShoulderCrossSlope=true

end try

catch

LeftInShoulderCrossSlpe=false

end catch




Autocad Civil 3D 2014 +SP1 // Civil 3D 2015
Quad Core Intel i7 3770-cpu 3.40Ghz.
ssd samsung 840 pro 512gb+ssd samsung 840 pro 256 gb+1tb hdd
32gb RAM 1600 Mhz.
nVidia Quadro 2000.
Win 7 Pro 64bit

Valued Mentor
joantopo
Posts: 644
Registered: ‎04-25-2010
Message 7 of 9 (76 Views)

Re: C3D 2012 SuperelevationCriticalStation.GetSlope VB.Net

09-29-2013 09:31 AM in reply to: joantopo

This is the exactly same sample.

http://wikihelp.autodesk.com/AutoCAD_Civil_3D/enu/2014/Help/API_Developer's_Guide/0059-Alignmen59/00...

Autocad Civil 3D 2014 +SP1 // Civil 3D 2015
Quad Core Intel i7 3770-cpu 3.40Ghz.
ssd samsung 840 pro 512gb+ssd samsung 840 pro 256 gb+1tb hdd
32gb RAM 1600 Mhz.
nVidia Quadro 2000.
Win 7 Pro 64bit

ADN Support Specialist
Partha.Sarkar
Posts: 543
Registered: ‎06-09-2009
Message 8 of 9 (57 Views)

Re: C3D 2012 SuperelevationCriticalStation.GetSlope VB.Net

10-03-2013 03:09 AM in reply to: joantopo

Hi,

 

Is this issue resolved through this link ?

Do you need any further help ?

 

Thanks,



Partha Sarkar
Developer Technical Services
Autodesk Developer Network

Valued Mentor
joantopo
Posts: 644
Registered: ‎04-25-2010
Message 9 of 9 (53 Views)

Re: C3D 2012 SuperelevationCriticalStation.GetSlope VB.Net

10-03-2013 04:36 AM in reply to: Partha.Sarkar

No. Thank you.

I was only adding more information.

Autocad Civil 3D 2014 +SP1 // Civil 3D 2015
Quad Core Intel i7 3770-cpu 3.40Ghz.
ssd samsung 840 pro 512gb+ssd samsung 840 pro 256 gb+1tb hdd
32gb RAM 1600 Mhz.
nVidia Quadro 2000.
Win 7 Pro 64bit

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Civil 3D Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for AutoCAD Civil 3D helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Civil 3D

Twitter

Facebook

Blogs