|
AcDbObjectId CreateHatch(
AcDbObjectId dbOId,
char cLayer[],
char cPattern[] = "SOLID",
int nColor = 256,
double dAngle = 0.0,
double dScale = 1.0,
AcDbDatabase * pDbDatab = acdbHostApplicationServices()->workingDatabase())
{
AcCmColor CmC;
AcDbObjectId DbOId;
AcDbObjectIdArray DbOIdA(0, 2);
AcDbBlockTable * pDbBT;
AcDbBlockTableRecord * pDbBTR;
AcGeVector3d normal(0.0, 0.0, 1.0);
DbOIdA.append(dbOId);
AcDbHatch* pDbHat = new AcDbHatch();
pDbHat->setDatabaseDefaults();
pDbHat->setAssociative(Adesk::kTrue); // BUG: doesn't do squat! have to set the reactor yourself to get associativity!
pDbHat->appendLoop(AcDbHatch::kExternal, DbOIdA);
pDbHat->setPatternScale(dScale);
pDbHat->setPatternAngle(dAngle);
pDbHat->setPattern(AcDbHatch::kPreDefined, cPattern);
pDbHat->setNormal(normal);
pDbHat->evaluateHatch(); // crucial call or nothing gets displayed!
pDbDatab->getSymbolTable(pDbBT, AcDb::kForRead);
pDbBT->getAt(ACDB_MODEL_SPACE, pDbBTR, AcDb::kForWrite);
pDbBTR->appendAcDbEntity(DbOId, pDbHat);
pDbHat->setLayer(cLayer);
CmC.setColorIndex(nColor);
((AcDbEntity *)pDbHat)->setColor(CmC);
pDbBT->close();
pDbBTR->close();
pDbHat->close();
return DbOId;
} |
|