Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
*joe
Message 1 of 3 (289 Views)

ObjectARX -> How to get attribute information from inserted block

289 Views, 2 Replies
03-19-2001 11:35 AM
I know how to insert a block with attribute information, but having trouble
to do it reversely.
I tried the following codes, Is it in right track? What is wrong and what to
do next?
Very appreciated for your help!
Joe

void CTest::GetAttribute(ads_name ent) {
AcDbObjectId id;
acdbGetObjectId(id, ent);

AcDbEntity *pEnt;
acdbOpenObject(pEnt, id, AcDb::kForRead);
if ((CString)pEnt->isA()->name() == "AcDbBlockReference") {
AcDbBlockReference *pBR;
pBR = AcDbBlockReference::cast(pEnt); // error -> undefined
AcDbBlockReference
AcDbObjectIterator *pI;
pI = pBR->attributeIterator();
pBR->close();

for (pI->start(); !pI->done(); pI->step()) {

}
delete pI;
}
Contributor
Jason_Tommell
Posts: 25
Registered: ‎10-29-2003
Message 2 of 3 (289 Views)

Re: ObjectARX -> How to get attribute information from inserted block

03-21-2001 01:59 AM in reply to: *joe
If I understand correctly, you want to select a block and then get to the attribute tag...Maybe try using acedNEntSelP or acedEntSel

retCode = acedEntSel("\nPick the Block:", ent, Pt)
switch(retCode)
{...}
acdbGetObjectId(eid, ent);
acdbOpenAcDbEntity(pEnt, eId, AcDb::kForRead);
//cast to see if its a block
//then create a attribute iterator

I am currently fighting with this and trying to get it to work...hope this is kind of what you are looking for.

jason
*joe
Message 3 of 3 (289 Views)

Re:

03-21-2001 02:14 PM in reply to: *joe
Thanks. I figured it out,
size=2>no cast is needed.

Check the following code, it
works!

Joe

 

 

retCode = acedEntSel("\nPick the Block:", ent, Pt)
switch(retCode)

{...}
acdbGetObjectId(eid, ent);
CTest *myTest =  new
CTest;

CString tagValue = myTest->GetAttribute(eid, "Tag:");

face=Arial size=2>...

 

// input -> block id and attribute tag
fileld

// output -> attribute tag value

CString CTest::GetAttribute(AcDbObjectId id,
CString ta) {
 AcDbBlockReference *pBR;
 acdbOpenObject(pBR, id,
AcDb::kForRead);

 

 AcDbObjectIterator *it;
 it =
pBR->attributeIterator();
 pBR->close();

 

 AcDbAttribute *pA;
 CString s1,
s2;
 for (it->start(); !it->done(); it->step()) {
 
acdbOpenObject(pA, it->objectId(), AcDb::kForRead);
  s1 =
pA->tag();
  if (s1 == ta)
   s2 =
pA->textString();
  pA->close();
 }
 delete
it;

 

 return s2;
}

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
If
I understand correctly, you want to select a block and then get to the
attribute tag...Maybe try using acedNEntSelP or acedEntSel

retCode = acedEntSel("\nPick the Block:", ent, Pt)
switch(retCode)

{...}
acdbGetObjectId(eid, ent);
acdbOpenAcDbEntity(pEnt, eId,
AcDb::kForRead);
//cast to see if its a block
//then create a
attribute iterator

I am currently fighting with this and trying to get it to work...hope this
is kind of what you are looking for.

jason

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community