Jump to content

Update "Prompt" tab in an existing Block Attribute.


jlobo

Recommended Posts

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();

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...