Drawings SDK Developer Guide > Working with .dwg Files > Working with Databases > Working with Database Containers > Working with Dictionaries of Objects > Working with Specific Dictionaries > Multi-Line Styles Dictionary > Organization of Multi-Line Styles
Organization of Multi-Line Styles

The database stores all multi-line styles in a dictionary. The multi-line style is an item of a standard dictionary which is placed in the root drawing dictionary of the database and has a unified dictionary interface for manipulating multi-line styles. The "ACAD_MLINESTYLE" keyword identifies the multi-line style dictionary object in the root.

The OdDbMlineStyle class is the multi-line style object that represents the interface for accessing a multi-line style and manipulating its properties. The OdDbDictionary class is used as a container for storing multi-line styles. The multi-line style object has the AcDbMlineStyle class name, and the multi-line style dictionary object has the AcDbDictionary class name.

The OdDbMlineStylePtr class is the typified smart pointer to an instance of the multi-line style and is used for storing and passing references to this object. In the following examples, the pDb variable stores a pointer to the database object.

To get the multi-line style dictionary, use the getMLStyleDictionaryId() method of the database object that has one argument — the preset status as a Boolean value — and returns the OdDbObjectId instance associated with the multi-line style dictionary object. For example:


OdDbObjectId idMLStyles = pDb->getMLStyleDictionaryId();

When the multi-line style dictionary exists in the database, this method returns the Object ID of the existing dictionary independent of the preset status (True or False). When the multi-line style dictionary is absent from the database and the preset status is False, this method returns OdDb::kNull. When the multi-line style dictionary is absent from the database and the preset status is True, this method creates a new dictionary, adds it in the root drawing dictionary, associates the "ACAD_MLINESTYLE" name with it, assigns a unique ID, and returns the Object ID of the created dictionary. The preset status is an optional argument and is True by default.

For example, to check the availability of the multi-line style dictionary and get its ID:


OdDbObjectId idMLStyles = pDb->getMLStyleDictionaryId(false);
if(idMLStyles.isNull())
  odPrintConsoleString(L"\nThe multi-line style's dictionary is absent from the database\n");
else
  odPrintConsoleString(L"\nThe multi-line style's dictionary has ID = %s\n", idMLStyles.getHandle().ascii().c_str());

For example, to get an existing multi-line style dictionary or create a new dictionary if it is absent from the database:


OdDbObjectId idMLStyles = pDb->getMLStyleDictionaryId(true);

To check the availability of the multi-line style dictionary and get its ID, you can also use the root drawing dictionary. For example:


OdDbDictionaryPtr pRoot = pDb->getNamedObjectsDictionaryId().safeOpenObject();

OdDbObjectId idMLStyles = pRoot->getAt(L"ACAD_MLINESTYLE");
  
if(!idMLStyles.isNull())
{
  odPrintConsoleString(L"\nThe multi-line style's dictionary has ID = %s\n", idMLStyles.getHandle().ascii().c_str());
}
else odPrintConsoleString(L"\nThe multi-line style's dictionary is absent from the database\n");

To manipulate multi-line styles, the program must open the multi-line style dictionary object and get a smart pointer to it. If this dictionary is opened in read mode, a program can obtain the multi-line style objects and their properties. If this dictionary is opened in write mode, the program can add a new multi-line style in the dictionary, rename any multi-line style, modify the properties of an existing multi-line style, or delete the multi-line style from the dictionary.

To get the smart pointer to the multi-line style dictionary object, declare a variable of the OdDbDictionaryPtr type and use the safeOpenObject() method of the obtained OdDbObjectId object. This method requires one argument — the mode to be opened as a value of the OdDb::OpenMode enumerator (kForRead, kForWrite, or kForNotify) — and returns a smart pointer to the object. For example:


// Open the multi-line style's dictionary in the read mode
OdDbDictionaryPtr pMLStyles = idMLStyles.safeOpenObject(OdDb::kForRead);

// Open the multi-line style's dictionary in the write mode
OdDbDictionaryPtr pMLStyles = idMLStyles.safeOpenObject(OdDb::kForWrite);

These operations can be united in one line:


OdDbDictionaryPtr pMLStyles = pDb->getMLStyleDictionaryId(true).safeOpenObject(OdDb::kForWrite);

The multi-line style dictionary has the standard dictionary interface for manipulating multi-line style objects.

See Also

Overview of Multi-Lines

Editing Multi-Line Style Caps

Specific Multi-Line Style Properties

Editing Multi-Line Style Elements

Manipulating the Multi-Line Styles in the Dictionary

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