Create A Layer Using Autodesk.AutoCAD.DatabaseServices

Land Desktop Map 3D Samples

 
Create A Layer Using Autodesk.AutoCAD.DatabaseServices
 
 
 

This method takes a layer name argument and returns an Autodesk.AutoCAD.DatabaseServices.ObjectId object that identifies an entry in an Autodesk.AutoCAD.DatabaseServices.LayerTable object. It does the following:

  1. Gets a reference to the Project.ProjectModel object which represents the active project.
  2. Uses the active project to get an Autodesk.AutoCAD.DatabaseServices.Database object and the latter to get an Autodesk.AutoCAD.DatabaseServices.TransactionManager object and the latter to get an Autodesk.AutoCAD.DatabaseServices.Transaction object. All of the following actions take place within the context of the transaction and have no effect in the database until the transaction commits.
  3. Gets a reference to the active project’s Autodesk.AutoCAD.DatabaseServices.LayerTable object.
  4. Uses the layer name to access the LayerTable object. If this fails, it carries on to create a layer in the layer table.
  5. Determines that a layer whose name is the layer name argument is not in the LayerTable object.
  6. Creates an Autodesk.AutoCAD.DatabaseServices.LayerTableRecord object, sets its Name property to be the layer name argument and adds it to the LayerTable object. The effect of this is that an ObjectData.Table object can be retrieved from the LayerTable object using the layer name as an index.