A hatch is an entity that represents an area filled with a pattern or gradient
that is bounded by a closed planar contour created from planar entities with
which it is associated. Engineers use hatches for sectioning arrangements in
drawings, for the texture of materials, and for gradient fields. The OdDbHatch
class is a hatch object that represents the interface for accessing a hatch
entity and manipulating its properties. The OdDbHatchPtr class is the typified
smart pointer to an instance of the hatch entity and is used for storing and
passing references to the hatch object.
To create an instance of the hatch object, use the createObject() method of the OdDbHatch class which is the static pseudo-constructor. For example:
OdDbHatchPtr pHatch = OdDbHatch::createObject();
The pseudo-constructor initializes the properties of a new instance using default
values. After creation, the new hatch instance must be added in model space,
paper space, or a block using the setDatabaseDefaults() and appendOdDbEntity()
methods. The database associates the object ID with the hatch instance. In the
following examples, the pDb variable stores a pointer to the database object.
For example:
pHatch->setDatabaseDefaults(pDb);
// Add in the block
OdDbBlockTablePtr pBlocks = pDb->getBlockTableId().safeOpenObject(OdDb::kForRead);
OdDbBlockTableRecordPtr pBlock = pBlocks->getAt(L"BLOCK", OdDb::kForWrite);
OdDbObjectId idHatch = pBlock->appendOdDbEntity(pHatch);
//Add in model space
OdDbBlockTableRecordPtr pModel = pDb->getModelSpaceId().safeOpenObject(OdDb::kForWrite);
pModel->appendOdDbEntity(pHatch);
// Add in the paper space
OdBlockTableRecordPtr pPaper = pDb->getPaperSpaceId().safeOpenObject(OdDb::kForWrite);
pPaper->appendOdDbEntity(pHatch);
The OdDbHatch class is derived from the OdDbEntity class, therefore the OdDbHatch class
also inherits the general properties of entities. A pointer to a hatch object
can be converted to an entity object. For example:
OdDbEntityPtr pEntity = pHatch;
A hatch object has the AcDbHatch class name. To find out whether an entity
is a hatch or it is derived from the OdDbHatch class, use the isKindOf() and
desc() methods. For example:
//Accurate comparing
if (pEntity->isA() == OdDbHatch::desc())
wcout << L"\nEntity is the hatch";
// Check the belonging
if (pEntity->isKindOf(OdDbHatch::desc()))
wcout << L"\nEntity is derived from the hatch";