Close

Relief for ODA Team in Ukraine

Learn more
ODA Drawings SDK
Overview of Multi-Polygons

A multi-polygon is an entity that represents one or more closed polygons as a single polygon. A polygon is an area filled with a pattern that is bounded by a closed planar contour. Working with multi-polygons is similar to working with hatches, as the multi-polygon uses the hatch functionality.

The OdDbMPolygon class represents the interface for accessing multi-polygon entities and manipulating their properties. The OdDbMPolygonPtr class is the typified smart pointer to an instance of a multi-polygon entity and is used for storing and passing references to multi-polygon objects.

To create an instance of the multi-polygon class, use the createObject() method of the OdDbMPolygon class which is the static pseudo-constructor. For example:

OdDbMPolygonPtr pMPolygon = OdDbMPolygon::createObject();

The pseudo-constructor initializes the properties of a new instance using default values. After creation, the new multi-polygon instance can be added in model space, paper space, or a block using the appendOdDbEntity() method. Before editing the properties of a multi-polygon entity, it must be added to the database or the database must be assigned for a multi-polygon entity by the setDatabaseDefaults() method. The database associates the object ID with the multi-polygon instance. In the following examples, the pDb variable stores a pointer to the database object. For example:

pMPolygon->setDatabaseDefaults(pDb);

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

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

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

The OdDbMPolygon class is derived from the OdDbEntity class, therefore the OdDbMPolygon class also inherits the general properties of entities. A pointer to a multi-polygon object can be converted to an entity object. For example:

OdDbEntityPtr pEntity = pMPolygon;

A multi-polygon object has the AcDbMPolygon class name. To find out whether an entity is a multi-polygon or it is derived from the OdDbMPolygon class, use the isKindOf() and desc() methods. For example:

// Accurate comparing
if (pEntity->isA() == OdDbMPolygon::desc())
  wcout << L"\nEntity is the MPolygon";

// Check the belonging
if (pEntity->isKindOf(OdDbMPolygon::desc()))
  wcout << L"\nEntity is derived from the MPolygon";

See Also

Working with Multi-Polygons

Working with Multi-Polygon Loops

Examples of Working with Multi-Polygons

OdDbMPolygon class

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