Close

Relief for ODA Team in Ukraine

Learn more
ODA Drawings SDK
Creating Layers

In a database, layers are stored as layer table records in the layer table. To create a new layer, create a new OdDbLayerTableRecord object and put it in the OdDbLinetypeTable object.

The following code fragment creates a new layer in the database and sets some of its properties.


  /**********************************************************************/
  /* Open the Layer Table                                               */
  /**********************************************************************/
  OdDbLayerTablePtr pLayers = pDb->getLayerTableId().safeOpenObject(OdDb::kForWrite);

  /**********************************************************************/
  /* Create a Layer Table Record                                        */
  /**********************************************************************/
  OdDbLayerTableRecordPtr pLayer = OdDbLayerTableRecord::createObject();

  /**********************************************************************/
  /* Layer must have a name before adding it to the table.              */
  /**********************************************************************/
  pLayer->setName("My Layer");

  /**********************************************************************/
  /* Add the record to the table.                                       */
  /**********************************************************************/
  OdDbObjectId layerId = pLayers->add(pLayer);

  /**********************************************************************/
  /* Set the Color.                                                     */
  /**********************************************************************/
  pLayer->setColorIndex(5);
  
  /**********************************************************************/
  /* Set the layer frozen.                                              */
  /**********************************************************************/
  pLayer->setIsFrozen(true);
Copyright © 2002 – 2022. Open Design Alliance. All rights reserved.