几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   DirectDWG (http://www.dimcax.com/hust/forumdisplay.php?f=89)
-   -   【转帖】getting attributes from block (http://www.dimcax.com/hust/showthread.php?t=16403)

yang686526 2009-05-05 11:27 AM

【转帖】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


所有的时间均为北京时间。 现在的时间是 06:28 AM.