Want to Add a SuperelevationCriticalStation using Civil 3D .NET API ?

By Partha Sarkar

In AutoCAD Civil 3D, SuperelevationCriticalStation class represents a super-elevation critical station on an Alignment object. And SuperelevationCriticalStationCollection class represents a collection of SuperelevationCriticalStation objects. SuperelevationCriticalStationCollection.Add() method adds a SuperelevationCriticalStation of the specified transition type at the specified station. For the list of SuperelevationCriticalStationType members, take a look into the SuperelevationCriticalStationType Enumeration in Civil 3D .NET API Reference document. 

Here is a C#  code snippet which demonstrates how to add a new critical station at a specified station value (double) with a SuperelevationCriticalStationType of BeginNormalCrown :

using (Transaction trans = db.TransactionManager.StartTransaction())

{
 
    Alignment align = trans.GetObject(alignmentId, OpenMode.ForWrite) as Alignment;
 
    // get the critical station collection on the aligment.
    SuperelevationCriticalStationCollection criteriaStationColl = align.SuperelevationCriticalStations;
 
    // add a new critical station at the station 1000.00 with a type BeginNormalCrown.
    // values used below can be tested using Civil 3D Tutorial sample DWG file - "Align-Superelevation-1.dwg " 
      criteriaStationColl.Add(1000.00, SuperelevationCriticalStationType.BeginNormalCrown);
 
      // get the critical station at the station 1000.00.
      SuperelevationCriticalStation scs1000 = criteriaStationColl.GetCriticalStationAt(1000.00, 0.01);
      scs1000.SetSlope(SuperelevationCrossSegmentType.LeftOutLaneCrossSlope, 0.05);
      //....
 
    trans.Commit();
}

 

And you are expected to see a result similar to this :

SuperElevn

Hope this helps !


Comments

3 responses to “Want to Add a SuperelevationCriticalStation using Civil 3D .NET API ?”

  1. Hi.
    I´m trying to do the same but SuperelevationCriticalStationType= BeginAlignment.
    BeginAlingment station=0
    // get the critical station at the station 0.000
    SuperelevationCriticalStation scs1000 = criteriaStationColl.GetCriticalStationAt(0, 0.01);
    scs1000.SetSlope(SuperelevationCrossSegmentType.LeftOutLaneCrossSlope, -0.02);
    But I Civil 3D doesn´t change slopes for BeginAlingment.
    If I edit a superelevations *.csv file (for the first row–>beginalignment slopes) and then export again the file, I neither change slopes.
    Help me, pleease.

  2. Hi joantopo,
    It seems to be working fine for me. I checked in Civil 3D 2014 (Win 7, 64 bit) and I could set the Slope for BeginAlignment.
    Could you check the slope value before you try to set it ?
    double getSlopeValue = scsStartStn.GetSlope(SuperelevationCrossSegmentType.LeftOutLaneCrossSlope);
    For me this worked fine –
    scsStartStn.SetSlope(SuperelevationCrossSegmentType.LeftOutLaneCrossSlope, -0.04);
    Thanks,
    Partha Sarkar
    ADN

  3. Hi guys, we have very first snippet code, what we already tried… to set superelevation values in editor table. The problem is, that Critical superelevation stations and its values are somehow disordered. Can you help me, why?
    CivilDocument doc = CivilApplication.ActiveDocument;
    using (Transaction tr = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.TransactionManager.StartTransaction())
    {
    foreach (ObjectId aligmentID in doc.GetAlignmentIds())
    {
    Alignment al = aligmentID.GetObject(OpenMode.ForWrite) as Alignment;
    SuperelevationCriticalStationCollection criteriaStationColl = al.SuperelevationCriticalStations;
    al.SuperelevationCriticalStations.Add(10, Autodesk.Civil.SuperelevationCriticalStationType.EndNormalCrown);
    SuperelevationCriticalStation st = criteriaStationColl.GetCriticalStationAt(10, 0.01);
    st.SetSlope(Autodesk.Civil.SuperelevationCrossSegmentType.LeftOutLaneCrossSlope, -0.025);
    st.SetSlope(Autodesk.Civil.SuperelevationCrossSegmentType.RightOutLaneCrossSlope, -0.025);
    al.SuperelevationCriticalStations.Add(30, Autodesk.Civil.SuperelevationCriticalStationType.LevelCrown);
    st = criteriaStationColl.GetCriticalStationAt(30, 0.01);
    st.SetSlope(Autodesk.Civil.SuperelevationCrossSegmentType.LeftOutLaneCrossSlope, 0);
    st.SetSlope(Autodesk.Civil.SuperelevationCrossSegmentType.RightOutLaneCrossSlope, -0.025);
    al.SuperelevationCriticalStations.Add(50, Autodesk.Civil.SuperelevationCriticalStationType.ReverseCrown);
    st = criteriaStationColl.GetCriticalStationAt(50, 0.01);
    st.SetSlope(Autodesk.Civil.SuperelevationCrossSegmentType.LeftOutLaneCrossSlope, 0.025);
    st.SetSlope(Autodesk.Civil.SuperelevationCrossSegmentType.RightOutLaneCrossSlope, -0.025);
    al.SuperelevationCriticalStations.Add(70, Autodesk.Civil.SuperelevationCriticalStationType.BeginFullSuper);
    st = criteriaStationColl.GetCriticalStationAt(70, 0.01);
    st.SetSlope(Autodesk.Civil.SuperelevationCrossSegmentType.LeftOutLaneCrossSlope, 0.07);
    st.SetSlope(Autodesk.Civil.SuperelevationCrossSegmentType.RightOutLaneCrossSlope, -0.07);
    al.SuperelevationCriticalStations.Add(110, Autodesk.Civil.SuperelevationCriticalStationType.EndFullSuper);
    st = criteriaStationColl.GetCriticalStationAt(110, 0.01);
    st.SetSlope(Autodesk.Civil.SuperelevationCrossSegmentType.LeftOutLaneCrossSlope, 0.07);
    st.SetSlope(Autodesk.Civil.SuperelevationCrossSegmentType.RightOutLaneCrossSlope, -0.05);
    al.SuperelevationCriticalStations.Add(130, Autodesk.Civil.SuperelevationCriticalStationType.ReverseCrown);
    st = criteriaStationColl.GetCriticalStationAt(130, 0.01);
    st.SetSlope(Autodesk.Civil.SuperelevationCrossSegmentType.LeftOutLaneCrossSlope, 0.025);
    st.SetSlope(Autodesk.Civil.SuperelevationCrossSegmentType.RightOutLaneCrossSlope, -0.025);
    al.SuperelevationCriticalStations.Add(150, Autodesk.Civil.SuperelevationCriticalStationType.LevelCrown);
    st = criteriaStationColl.GetCriticalStationAt(150, 0.01);
    st.SetSlope(Autodesk.Civil.SuperelevationCrossSegmentType.LeftOutLaneCrossSlope, 0);
    st.SetSlope(Autodesk.Civil.SuperelevationCrossSegmentType.RightOutLaneCrossSlope, -0.025);
    al.SuperelevationCriticalStations.Add(170, Autodesk.Civil.SuperelevationCriticalStationType.BeginNormalCrown);
    st = criteriaStationColl.GetCriticalStationAt(170, 0.01);
    st.SetSlope(Autodesk.Civil.SuperelevationCrossSegmentType.LeftOutLaneCrossSlope, -0.025);
    st.SetSlope(Autodesk.Civil.SuperelevationCrossSegmentType.RightOutLaneCrossSlope, -0.025);
    }
    tr.Commit();
    }
    Thanks
    Martin

Leave a Reply to Partha SarkarCancel reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading