高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】getting attributes from block
getting attributes from block
getting attributes from block
hi,
please help me to solve the below issue.
the autocad file contains 'kc-title' block. the block contain mutliple attributes like
name, value
size, 2
title1, diaper
title2, mechanical
and so on. now what is the problem is i can able to read the attribute names(size, title1,title2) from the block. but the attribute value(2, diaper, mechanical) is displayed null.
odstring s;
oddbblocktableptr ptable = pdb->getblocktableid().safeopenobject();
oddbsymboltableiteratorptr pblkiter = ptable->newiterator();
for (pblkiter->start(); ! pblkiter->done(); pblkiter->step())
{
oddbblocktablerecordptr pblock = pblkiter->getrecordid().safeopenobject();
s=pblock->getname();
odprintconsolestring(l"%ls\n", s.c_str());
if(pblock->hasattributedefinitions())
{
oddbobjectiteratorptr pentiter = pblock->newiterator();
for (; !pentiter->done(); pentiter->step())
{
dumpentity(pentiter->objectid(), 1);
}
}
}
void dumpentity(oddbobjectid id, int indent)
{
odstring s,buffer;
oddbentityptr pent = id.openobject();
oddbattributedefinitionptr pattdef = oddbattributedefinition::cast(pent);
if(!pattdef.isnull())
{
s = pattdef->tag()+"---"+pattdef->textstring();
odprintconsolestring(l"%s\n",s.c_str());
}
}
please provide any sample program for the above problem. please see the attached dwg file for your reference..
attached files
oddbattributedefinitions are contained in block.
oddbattributes (actual values) are owned by oddbblockreference entity (block insertion).
different insertions of the same block can have different attribute values.
to get attribute values use oddbblockreference::attributeiterator()
sergey slezkin
|