Drawings SDK Developer Guide > Working with .dwg Files > Working with Databases > Working with Database Containers > Working with Predefined Tables of Named Records > Working with Specific Predefined Tables of Named Records > Linetypes Table > Organization of Linetypes
Organization of Linetypes

The database stores all linetypes in the linetype table. The linetype is a record of the linetype table. The linetype table is a predefined object that exists in the database initially and cannot be deleted. The database contains a set of predefined linetypes that also exists initially in the linetype table and also cannot be deleted.The OdDbLinetypeTable class is the linetype table object that represents the interface for accessing the linetype table and manipulating the linetypes in it. The OdDbLinetypeTableRecord class is the linetype record object that represents the interface for accessing linetypes and manipulating their properties. The linetype table object has the AcDbLinetypeTable class name; the linetype record object has the AcDbLinetypeTableRecord class name.

The OdDbLinetypeTablePtr class is the typified smart pointer to an instance of the linetype table and is used for storing and passing references to the linetype table object. The OdDbLinetypeTableRecordPtr class is the typified smart pointer to an instance of the linetype and is used for storing and passing references to the linetype record object.

In the examples below, the pDb variable stores the pointer to the database object.

To get the linetype table, use the getLinetypeTableId() method of the database object; it does not have arguments and returns the OdDbObjectId instance associated with the linetype table object. For example:


OdDbObjectId idLinetypes = pDb->getLinetypeTableId();

To manipulate linetypes, the program must open the linetype table object and get the smart pointer to it. If the linetype table object is opened in read mode, the program can obtain the linetypes and their properties, but it cannot modify them, add a new linetype, or delete an existing linetype from the table. If the linetype table object is opened in write mode, the program can add a new linetype in the table, rename any linetype, modify the properties of an existing linetype, or delete the linetype from the table.

To get the smart pointer to the linetype table object, declare a variable of the OdDbLinetypeTablePtr type and use the safeOpenObject() method of the obtained OdDbObjectId object. The linetype table is a predefined object and the erase status is not applicable for it. Therefore, the safeOpenObject() method requires only the open mode as a value of the OdDb::OpenMode enumerator (kForRead, kForWrite, or kForNotify) and returns the smart pointer to the linetype table object. For example:


// Open the linetype table object in the read mode
OdDbLinetypeTablePtr pLinetypes = idLinetypes.safeOpenObject(OdDb::kForRead);

// Open the linetype table object in the write mode
OdDbLinetypeTablePtr pLinetypes = idLinetypes.safeOpenObject(OdDb::kForWrite);

These operations can be combined in one line:


OdDbLinetypeTablePtr pLinetypes = pDb->getLinetypeTableId().safeOpenObject(OdDb::kForWrite);

The linetype table object contains three predefined linetypes, named "Continuous", "ByLayer", and "ByBlock", which are used as default objects associated with other objects of the database. The "ByLayer" linetype record object is used when the Linetype property of an entity is set to the "ByLayer" value and the entity uses the properties of the layer to which it belongs. The "ByBlock" linetype record object is used when the Linetype property of an entity is set to the "ByBlock" value and the entity uses the properties of the block in which it is composed. The "Continuous" linetype record object is used as a linetype by default.

To get the "ByLayer" linetype, use the getLinetypeByLayerId() method of the database. To get the "ByBlock" linetype, use the getLinetypeByBlockId() method of the database. To get the "Continuous" linetype, use the getLinetypeContinuousId() method of the database. These methods return the OdDbObjectId instance associated with the corresponding linetype. For example:


OdDbLinetypeTableRecordPtr pByLayer = pDb->getLinetypeByLayerId().safeOpenObject();
odPrintConsoleString(L"\nThe byLayer linetype is \"%ls\"", pByLayer->getName().c_str());

OdDbLinetypeTableRecordPtr pByBlock = pDb->getLinetypeByBlockId().safeOpenObject();
odPrintConsoleString(L"\nThe byBlock linetype is \"%ls\"", pByBlock->getName().c_str());

OdDbLinetypeTableRecordPtr pContinuous = pDb->getLinetypeContinuousId().safeOpenObject();
odPrintConsoleString(L"\nThe Continuous linetype is \"%ls\"", pContinuous->getName().c_str());

The linetype table object has the following specific methods: add() method for adding a new linetype to the table, getAt() method for getting an existing linetype from the table, has() method for checking whether the linetype exists in the table, and newIterator() method for iterating through linetypes of the table.

See Also

Working with Linetypes

Manipulating of Linetypes

Working with Predefined Tables of Named Records

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