Accessing the ‘Object Layers’ using Civil 3D .NET API

By Partha Sarkar

Civil 3D COM
API IAeccSettingsObjectLayer:: Layer
gives us access to get or set the layer name on which the object is drawn.
However, if we take a closer look into the Object list in the 'Object Layers'
tab under "Drawing Settings" dialog box in Civil 3D, we will find
there are some objects which are not covered by IAeccSettingsObjectLayers. Most likely they were added later stage
by the time we shifted focus to .NET API in Civil 3D. And the good news is, most
of those objects are accessible through .NET API. Here is an example:

 

Object_Layers

 

In the above screenshot, we see Objects like "Pipe",
"Pipe-Labeling". They are not accessible through COM API IAeccSettingsObjectLayers. However, we
can use .NET API and access them and know the Layer name. Here is a c# code snippet:

CivilDocument civilDoc = CivilApplication.ActiveDocument;
using (Transaction ts = Application.DocumentManager.MdiActiveDocument.Database
  .TransactionManager.StartTransaction())
{
 
  SettingsDrawing settingsDWG = civilDoc.Settings.DrawingSettings;
  String layerName = settingsDWG.ObjectLayerSettings
    .GetObjectLayerSetting(SettingsObjectLayerType.Pipe).LayerName.ToString();
  ed.WriteMessage("nDrawing Settings - Object Layers - Pipe Layer Name : " + layerName);
  ts.Commit();
}

 

And Result in
Civil 3D 2013:

DWG_Settings_Pipe_ObjLayer

 

Hope this is
useful to you!