Drawings SDK Developer Guide > Working with .dwg Files > Introduction > Drawing Database Overview > Ownership of Database Objects
Ownership of Database Objects

There are two main types of objects inside a database: containers and objects themselves. There is a nested structure where there are ten root container objects: the nine symbol tables and the named object dictionary which contains objects or other containers.

Objects can belong to the database or not. An object is considered to be owned by the database (database resident object) if it has been added to the appropriate container. For example, a Layer object belongs to the database if it's added to the layer table container, a Block object belongs to the database if it's added to the block table, and an entity belongs to the database if it's added to a block table record that is in the block table, and so on. Objects that are not put in the database are non-resident objects.

For example, the procedure of creating a new layer object inside the database looks like:

  1. Open the Layer Table object, that is the container for all layers (Layer Table Record objects), for writing.
  2. Create a new Layer Table Record object that represents the layer.
  3. Set some properties for the layer. The Name property must be set before adding the layer to the database.
  4. Put the Layer object into the database, adding to the layer table.

Another example is creating an entity inside model space of the drawing. Here is the procedure:

  1. Open the Block Table object, that is the container for all blocks (Block Table Record objects) which contain all entities of the drawing.
  2. Open the block table record that represents the Model Space block inside the drawing.
  3. Create a new entity object.
  4. Add the entity object to the Model Space block table record object.

Since a created object becomes a database resident object, its lifecycle is managed by the database.

Copyright © 2002 – 2021. Open Design Alliance. All rights reserved.