几何尺寸与公差论坛------致力于产品几何量公差标准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)
-   -   【转帖】basic question about explodegeometrytoblock (http://www.dimcax.com/hust/showthread.php?t=15208)

yang686526 2009-05-04 04:38 PM

【转帖】basic question about explodegeometrytoblock
 
basic question about explodegeometrytoblock
basic question about explodegeometrytoblock
hello,
i am certainly doing some very basic stuff wrong. i am trying to explode a oddbentity ("ent" in the following code) into a block. but all ids turn out to be zero. the entity originates from an iteration over the entities of a modelspace of a preiously opened database. i do have access to all properties of the entity, which in my case is a mtext entity.
code:
odsmartptr<oddbblocktablerecord> res = oddbblocktablerecord::createobject();
oddbobjectidarray ids;
odresult ok = ent->explodegeometrytoblock(res, &ids);
int l = ids.length();
for (int i=0; i<l; ++i)
{
if (!(ids[i].isnull()))
{
oddbobjectid id = ids[i];
oddbobjectptr entity = id.safeopenobject();
}
}i broke the code down from a c# program where i am using a c# wrapper to dwgdirect, so i could test it with c++. so my code may look a bit awkward.
thank you for any hint and especially a for a reference where i would have found the solution myself.
gerhard
you explode entities to a non-database resident block, therefore explode results are ndbro too, they have no ids.
vladimir
thank you vladimir!
this was the information i was missing. where could i have found it?
i had to safeopenobject the blocktableid of the database as oddb::kforwrite and then add my oddbblocktablerecord to that database. now it works.
thanks
gerhard
quote:
where could i have found it?
i don't think it is explicitly stated anywhere. it is just logical - object id is a property of a database resident object, i.e. no database = no object id.
vladimir


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