|
[code]void AddNewAtt()
{
AcDbDatabase *pCurDb;
AcDbBlockTable* pBlkTbl;
AcDbBlockTableRecord* pBlkRec;
AcDbObjectId attId;
Acad::ErrorStatus es;
AcDbAttributeDefinition* pAttDef;
// location of the AttributeDefinition in the
// block definition
AcGePoint3d attLoc(1.2, -0.5, 0);
// specify the text,tag and prompt
ACHAR text[] = {L"NEW VALUE ADDED"};
ACHAR tag[] = {L"MYTAG"};
ACHAR prompt[] = {L"Enter a new value"};
pCurDb =
acdbHostApplicationServices()->workingDatabase();
es =
pCurDb->getBlockTable(pBlkTbl, AcDb::kForRead);
if(!pBlkTbl->has(L"TEST"))
{
acutPrintf(L"\nBlock definition TEST does not
exist");
pBlkTbl->close();
return;
}
es = pBlkTbl->getAt(L"TEST", pBlkRec, AcDb::kForWrite);
// create a AttributeDefinition
pAttDef = new AcDbAttributeDefinition(attLoc, text,
tag, prompt);
// append the AttributeDefinition to the definition
es = pBlkRec->appendAcDbEntity(attId, pAttDef);
pAttDef->close();
pBlkRec->close();
pBlkTbl->close();
}
[/code] |
|