Get / Set SuperelevationOptions using AutoCAD Civil 3D .NET API

By Partha Sarkar

If we refer
to AutoCAD Civil 3D API reference document for SuperelevationOptions,
we see most of the properties are Get as shown in the screenshot below –

 

Civil3D_SuperelevationOptions_01

If you are
wondering why these are only Get and how do we set these properties using API,
answer is, their values are Get and Set and we can use the appropriate property
and it’s value to set as per our project requirement.

Here is an
example using C# .NET API –

Default
settings before we make a change using API –

Civil3D_SuperelevationOptions_02

Here is the
code snippet –

using (Transaction trans = db.TransactionManager.StartTransaction())
{
  SettingsAlignment alignmentSettings = civilDoc.Settings.GetSettings(); 
  ed.WriteMessage("nSuperelevationOptions.CorridorType Before Set :" +
      alignmentSettings.SuperelevationOptions.CorridorType.Value.ToString() +
      "nSuperelevationOptions.NominalWidth Before Set  :" +
      alignmentSettings.SuperelevationOptions.NominalWidth.Value.ToString());
 
    // Values are Get / Set
  alignmentSettings.SuperelevationOptions.CorridorType.Value = SuperelevationCorridorType.Divided;
  alignmentSettings.SuperelevationOptions.NominalWidth.Value = 8.2;          
 
  trans.Commit();   
}

 

And changed
values after we run our custom code –

Civil3D_SuperelevationOptions_afterChange

Hope this helps
!


Comments

Leave a Reply

Discover more from Autodesk Developer Blog

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

Continue reading