Drawings SDK Developer Guide > Working with .dwg Files > Working with Entities > Working with Specific Entitites > Working with Multi-Lines > Overview of Multi-Lines
Overview of Multi-Lines

A multi-line is an entity that specifies a broken line in world space. A multi-line consists of multiple parallel lines in linear segments that are connected one to another so that the end of the current segment is the start of the next segment. All lines in each segment are parallel and are placed in same plane. A multi-line is used for various implementations, for example, plans of roads, highways, chart of gas or water mains, etc.

A multi-line entity stores a set of vertices and segments that define its geometry and settings that define its appearance. A multi-line entity is associated with a multi-line style which defines the number of parallel lines, their offsets, colors, and linetypes, and the shape of the start and end caps. A multi-line entity and multi-line style are objects that work together. To draw a multi-line entity, you must specify a multi-line style. If you change a multi-line style, all multi-line entities associated with that multi-line style change their appearance. The OdDbObjectId object provides the association.

Note: If a multi-line style is changed, entities will not change their appearance until they are edited (they store a kind of geometry cache).

The OdDbMline class is a multi-line object that represents the interface for accessing a multi-line entity and manipulating its properties. The OdDbMlinePtr class is the typified smart pointer to an instance of the multi-line entity and is used for storing and passing references to this object.

To create an instance of the multi-line object, use the createObject() method of the OdDbMline class that is the static pseudo-constructor. For example:


OdDbMlinePtr pMLine = OdDbMline::createObject();

The pseudo-constructor initializes the properties of a new instance using default values. After creating, the new multi-line instance must be added in model space, paper space, or a block using the appendOdDbEntity() method. The database associates the object ID with the created instance. In the following examples, the pDb variable stores a pointer to the database object. For example:


// Add in the block
OdDbBlockTablePtr pBlocks = pDb->getBlockTableId().safeOpenObject(OdDb::kForRead);
OdDbBlockTableRecordPtr pBlock = pBlocks->getAt(L"BLOCK", OdDb::kForWrite)
OdDbObjectId idMLine = pBlock->appendOdDbEntity(pMLine);

// Add in the model space
OdDbBlockTableRecordPtr pModel = pDb->getModelSpaceId().safeOpenObject(OdDb::kForWrite);
pModel->appendOdDbEntity(pMLine);

// Add in the paper space
OdDbBlockTableRecordPtr pPaper = pDb->getPaperSpaceId().safeOpenObject(OdDb::kForWrite);
pPaper->appendOdDbEntity(pMLine);

The OdDbMLine class is derived from the OdDbEntity class and inherits the general properties of entities. A pointer to the multi-line object can be converted to an entity object. For example:


OdDbEntityPtr pEntity = pMLine;

The multi-line object has the AcDbMLine class name. To verify an instance, use the isKindOf() and desc() methods. For example:


// Accurate comparing
if(pEntity->isA() == OdDbMLine::desc())
  OdConsoleString(L"\nEntity is the multi-line");

// Check on belonging
if(pEntity->isKindOf(OdDbMLine::desc()))
  OdConsoleString(L"\nEntity is derived from the multi-line object");

Specific Multi-Line Properties

Editing Multi-Line Vertices

Organization of Multi-line Styles

Example of Working with the Multi-Line Object

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