oddbobject::iskindof failing..
oddbobject::iskindof failing..
hi all,
i am trying to find if given object is a block or not.
here is the code snippet..
pent is valid oddbentity..
bool exchangexdata;
oddbobjectid replaceid;
oddbobjectptr pnewobj = pent->decomposeforsave(oddb::vac12, replaceid, exchangexdata);
oddbobject *pobjptr = pnewobj.get();
if(pobjptr->iskindof(oddbblockreference::desc())) ***this is failing**
{
}
i checked the pobjptr which is valid, it has oddbblockreference, but still it is failing..
anyone has any idea??
thanks for your help..
hi,
what is your toolkit version? did you use our sample as base for your application ?
mfcapp has method cdwgview:

neditacisconversion() . this is sample method for generation mesh from 3dsolids - convert all 3dsolids\regions\bodies from modelspace to mesh. it uses decomposeforsave too. decomposeforsave returns oddbblockreference to block with mesh entities. you can test
if (pnewobj->iskindof(oddbblockreference::desc()))
in this place. it works fine for me.
each dbclass has ::rxinit method. this method should be called at application initialization. this is why i asked you about 'base for your application'. our samples have valid initialization at start moment.
what kind of failure do you have?
btw, the code below
code:
oddbobjectptr pnewobj = pent->decomposeforsave(oddb::vac12, replaceid, exchangexdata);
oddbobject *pobjptr = pnewobj.get();
if(pobjptr->iskindof(oddbblockreference::desc()))
{can be replaced with
code:
oddbobjectptr pnewobj = pent->decomposeforsave(oddb::vac12, replaceid, exchangexdata);
if(pnewobj->iskindof(oddbblockreference::desc()))
{in general using oddbobject* to store a value which is returned from a function as oddbobjectptr is not safe because if no smart pointer to object exists than the object can be closed if it's database resident or deleted if it is not database resident. oddbobject* pointer will be invalid in such case.
failure was, directly going to catch after that iskindof() method call..
i think thats what happening here.
oddbobject* is ndro, so it is failing.
if i use direct smart pointer it works fine..
thanks for ur help..