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

yang686526 2009-05-04 05:51 PM

【转帖】cloning a database
 
cloning a database
cloning a database
hi,
how can i clone a database with dd 2.05.02 ?
in dd 2.03.00, we were using this code:
code:
oddbdatabaseptr newdatabaseptr;
newdatabaseptr = mcurrentoddbdatabase->wblock();but in dd 2.05.02 wblock doesn't works (
the only workaround is using wblockcloneobjects.
see examples\excustobjs\drxdebugcmds.cpp, _wblockclone_func, 2517
you should clone all block table records.
vladimir
thanks for your advices vladimir, but i can't reproduce the same behavior between wblockcloneobjects and wblock.
you say:
quote:
you should clone all block table records
this is the code that clone layout blocktablerecord:
code:

oddbdatabaseptr _wblock(oddbdatabase *poddbdatabase)
{
oddbobjectidarray outobjids;
oddbsymboltableptr oddbsymboltableptr = poddbdatabase->getblocktableid().safeopenobject();
oddbsymboltableiteratorptr oddbsymboltableiteratorptr = oddbsymboltableptr->newiterator();
for (oddbsymboltableiteratorptr->start(); !oddbsymboltableiteratorptr->done(); oddbsymboltableiteratorptr->step())
{
oddbsymboltablerecordptr oddbsymboltablerecordptr = oddbsymboltableiteratorptr->getrecordid().safeopenobject();
if (oddbsymboltablerecordptr->isa() == oddbblocktablerecord::desc())
{
oddbblocktablerecordptr oddbblocktablerecordptr = oddbsymboltablerecordptr;
if (oddbblocktablerecordptr->islayout() == true)
{
outobjids.append(oddbblocktablerecordptr->objectid());
}
}
}
oddbdatabaseptr oddbdatabaseptrret = appservices()->createdatabase(true, poddbdatabase->getmeasurement());
oddbidmappingptr pmap = oddbidmapping::createobject();
pmap->setdestdb(oddbdatabaseptrret);
try
{
poddbdatabase->wblockcloneobjects(outobjids, oddbdatabaseptrret->getblocktableid(), *pmap, oddb::kdrcreplace);
}
catch(const oderror& oderror)
{
cstring str = oderror.description();
oddbdatabaseptrret = null;
}
catch(...)
{
oddbdatabaseptrret = null;
}
return oddbdatabaseptrret;
}but in the destination database, i can't find modelspace entities of the source database.
ca you help me ? or fix the wblock bug ?
regards.
indeed, cloning block table record does not clone objects.
you should clone them separately.
vladimir
strange, because if i clone a paper space layout, all his entities are also cloned.
in attachment, the result of cloning a database with oddbdatabase::wblock (dd_2.03.00.jpg) and my _wblock function (dd_2.05.02.jpg).
result.dwg is the cloned database of odamfc1.
it is not the same result... and you can see that paper space layout have entities.
attached images (155.3 kb, 5 views)
(140.4 kb, 4 views)


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