高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】change layername for an entity
change layername for an entity
change layername for an entity
hi!
i need to change the name on existing entities. the "m_sset" holds the entities. i try to use "setlayer" with no success. since i'm a "newbie" to this stuff i guess it's something basic i'm doing wrong. all help you guys can give me is highly appreciated.
code:
oddbobjectptr pobject;
//iterate through the entity array
for( int i = 0; i < (int)m_sset.length(); i++ )
{
oddbobjectid myoddbobjectid = m_sset.getat(i);
pent = myoddbobjectid.openobject(oddb::kforwrite); //open entity for writing
if (!pent.isnull())
{
pblk = pent->ownerid().openobject(oddb::kforwrite); //open block for writing
if (!pblk.isnull())
{
if (pent->explodegeometrytoblock(pblk) == eok)
{
pobject = m_sset.getat(i).openobject(oddb::kforwrite);
pent->openedformodify( pobject );
pent->setlayer(_t("outer contour"));
}
}
}
}regards.
kennet
1. the layer "outer contour" must present in database.
2. you explode the source entity and than change its layer (not the resulting entities). after explode both source entity and result of its explode present in the block.
3. call for openedformodify() makes no sense. this function is called from inside of id.openobject(oddb::kforwrite). its a callback for custom entities to inform them that they are about to be modified.
sergey slezkin
|