jlobo Posted March 24, 2014 Share Posted March 24, 2014 I need to update the tag, prompt, value tab in the current block attribute. I can change the tag and the value tab but not the prompt. Any help will be appreciated. The approach am taking is; AcDbDatabase *dwgDb; AcDbBlockTable *pBlockTbl; AcDbBlockTableRecord *pModelSpaceTblRcd; AcDbBlockTableRecordIterator *pModelSpaceItr; AcDbEntity *pEntity; AcDbBlockReference *pBlockRef; AcDbAttribute *pAttribute; AcDbObjectIterator *pAttrItr; AcDbObject *pObject; TCHAR tagBuffer[sINGLE_LINE_INPUT_LENGTH_SHORT]; // Prepare attribute location measurements AcDbObjectId idOfEntity; dwgDb = NULL; dwgDb = acdbHostApplicationServices()->workingDatabase(); if (dwgDb == NULL) { AfxMessageBox(_T("Internal Error !")); return false; } dwgDb->getSymbolTable(pBlockTbl, AcDb::kForWrite); pBlockTbl->getAt(ACDB_MODEL_SPACE, pModelSpaceTblRcd, AcDb::kForWrite); pBlockTbl->close(); // Get an iterator to that we can iterate / pinpoint // the desired entity via the objectID pModelSpaceTblRcd->newIterator(pModelSpaceItr); // Go to the block reference / objectID if(pModelSpaceItr->seek(thePANBLKBlockId) != Acad::eOk) { AfxMessageBox(_T("Internal Error !")); delete pModelSpaceItr; pModelSpaceTblRcd->close(); return false; } // Access the block reference pModelSpaceItr->getEntity(pEntity, AcDb::kForWrite); pBlockRef = AcDbBlockReference::cast(pEntity); // Prepare iterator to move through block's attributes pAttrItr = pBlockRef->attributeIterator(); for(pAttrItr->start(); !pAttrItr->done(); pAttrItr->step()) { acdbOpenAcDbObject(pObject, pAttrItr->objectId(), AcDb::kForWrite); pAttribute = AcDbAttribute::cast(pObject); _tcscpy_s(tagBuffer, SINGLE_LINE_INPUT_LENGTH_SHORT, pAttribute->tag()); pAttribute->upgradeOpen(); // LEFTBFHGT if(_tcscmp(tagBuffer, _T("LEFTBFHGT")) == 0 || _tcscmp(tagBuffer, _T("LEFTHEIGHT")) == 0 ) { TCHAR attrText[COMMENT_LENGTH_SHORT]; _tcscpy_s(attrText, COMMENT_LENGTH_SHORT, pAttribute->textString() ); AcDbAttributeDefinition *tempAttrDefinition = new AcDbAttributeDefinition(); tempAttrDefinition->setPosition(pAttribute->position() ); tempAttrDefinition->setTag(_T("LEFTFFHGHT")); tempAttrDefinition->setPrompt(_T("Left Front Face Height.")); tempAttrDefinition->setTextStyle(idTextStyleLeroy); tempAttrDefinition->setHeight(.32); tempAttrDefinition->setRotation(0); pAttribute->setAttributeFromBlock(tempAttrDefinition, pBlockRef->blockTransform() ); pAttribute->transformBy(pBlockRef->blockTransform() ); pAttribute->downgradeOpen(); pModelSpaceTblRcd->appendAcDbEntity(pEntity); pBlockTbl->upgradeOpen(); pModelSpaceTblRcd->upgradeOpen(); tempAttrDefinition->close(); } pAttribute->close(); } // Free the attribute iterator delete pAttrItr; pBlockRef->close(); delete pModelSpaceItr; pModelSpaceTblRcd->close(); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.