incorrect block with attributes
incorrect block with attributes
hi,
can any one help me to find the solution for the below problem
i want to read attributes from the 'kc-title' block. the 'kc-title' block contains attributes like title1, title2, drawingid and so on... when reading kc-title block it doesn't show any attributes. instead all the above attributes are displayed under *paper-space block.
oddbobjectid blocktableid = pdb->getblocktableid();
oddbsymboltableptr pblocktable = blocktableid.safeopenobject();
oddbblocktablerecordptr pblock = pblocktable->getat("kc-title);
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();
oddbblockreferenceptr pblkref = oddbblockreference::cast(pent);
if (!pblkref.isnull())
{
oddbobjectiteratorptr piter = pblkref->attributeiterator();
for (int i=0; !piter->done(); i++, piter->step())
{
oddbattributeptr pattr = piter->entity();
if (!pattr.isnull())
{
oddbtextptr ptext = oddbtext::cast(pattr);
s = ptext->textstring();
buffer = pattr->tag()+ "---"+s;
odprintconsolestring(l"%ls\n", buffer.c_str());
}
}}
the above code displays nothing....
when i changing the above red line code,
oddbblocktablerecordptr pblock = pblocktable->getat("*paper_space);
the attributes are displayed...
your dump showes the entities inside the blockdefinition of "kc-title", but the oddbattributes are related to the references of "kc-title"-block , that磗 why the "bugfix" works. these oddbblockreferences are stored in paperspace-block.
quote:
originally posted by
uspiess@nemetschek.com
your dump showes the entities inside the blockdefinition of "kc-title", but the oddbattributes are related to the references of "kc-title"-block , that磗 why the "bugfix" works. these oddbblockreferences are stored in paperspace-block.
hi,
thanks for your reply.
i can able to get the attribute name using the below code... but the attribute value is displayed null. ie attribute names title1, title2 is displayed but the corresponding attribute values is not displayed. please give me the solution for getting attribute value and also clarify whether the below code is correct or not
oddbblocktableptr table = pdb->getblocktableid().safeopenobject();
oddbsymboltableiteratorptr i;
oddbattributedefinitionptr pattdef;
for (i = table->newiterator(); i->done() == false; i->step())
{
oddbblocktablerecordptr record = i->getrecord();
s = record->getname();
odprintconsolestring(l"%s\n",s.c_str());
for (oddbobjectiteratorptr objptr = record->newiterator(); objptr->done() == false ; objptr->step())
{
oddbentityptr entity = objptr->entity();
pattdef = oddbattributedefinition::cast(entity);
if((!pattdef.isnull()))// && (!pattdef->isconstant()))
{
buffer = pattdef->tag();
odprintconsolestring(l"%s\n",buffer.c_str());//name is displayed correctly
pattdef->textstring();
odprintconsolestring(l"%s\n",buffer.c_str());//displayed nothingfff">
}
last edited by
madhavan.mohanarangam@kcc.com; 19th january 2009 at 10:10 pmfff">.
hi, at the moment you read the attributedefinitions inside the blockdefinition.
what i undersztand is, you need the attribute values from the blockreferences of kc-title.
for this search the blockreference of kc-title e.g. inside paperspace-block and than
take the oddbblockreference::attributeiterator() const and step throw the attributes.
code:
oddbobjectiteratorptr it = pblockreferencefff">->attributeiterator();
// save the content of the attribs
for ( it->start () ; !it->done () ; it->step () )
{
oddbattributeptr fff">pattrib = it->entity ();
if ( !pattrib.isnull () )
{
buffer = pattrib->tag();
odprintconsolestring(l"%s\n",buffer.c_str());
buffer = pattrib->textstring();
odprintconsolestring(l"%s\n",buffer.c_str());
}