插入块
void insertBlock(LPCWSTR blockname){
// Find the block ID
AcDbDatabase *db = acdbHostApplicationServices()->workingDatabase();
Acad::ErrorStatus es;
AcDbBlockTable *pBlockTable;
AcDbObjectId blockId;
es = db->getBlockTable(pBlockTable, AcDb::kForRead);
if (es == Acad::eOk)
{
es = pBlockTable->getAt(blockname, blockId);
pBlockTable->close();
}
// Ask for insertion point
AcGeVector3d vec;
int stat = acedGetPoint(nullptr, L"\nInsertion point: ", asDblArray(vec));
if (stat != RTNORM)
return;
// Create the BREF
AcDbBlockReference *bref = new AcDbBlockReference();
bref->setDatabaseDefaults(db); // will set current layer, color and linetype
bref->setBlockTableRecord(blockId);
AcGeMatrix3d trans;
trans.setToTranslation(vec);
bref->setBlockTransform(trans);
// <add Code to modify layer or color here>
postToDb(bref); // Post to DB. See <ARX>\samples\entity\polysamp\utilui.cpp
}
页:
[1]