高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】explodetoblock - external references
explodetoblock - external references
explodetoblock - external references
i am wanting to convert external references from a dwg file to our format. we currently do this with standard blocks by using oddbblockreference::explodetoblock(), which works well.
when i try this with it generates a number of oderror_duplicaterecordname errors, and eventually throws an "invalid owner object" exception.
i also looked at calling xrefdatabase to generate another database pointer, and recursively process each file for each reference. (i need a transformation matrix to position this correctly. in the past when my predecessor did this with 'standard blocks' he couldn't get this to work) this method also generates a number of oderror_duplicaterecordname, but throws an unknown exception.
could someone point me in the direction of some sample code that deals with external references please?
ddt version <=1.11 used simple inserting for xref loading. since 1.12 version ddt places xref in a separate database which can be accessed through oddbblocktablerecord::xrefdatabase() method.
we've fixed some bugs related to exploding xref inserts in 1.12.04 revision. but exploding xref inserts can produce incorrect drawing (while exploding xref inserts if xref drawing contains blocks with the same name as in the main drawing the blocks from the main drawing will be used). autocad does not explode xref inserts probably for this reason and we are going to refuse exploding xref insertions too.
oddbxrefman::bind() is intended for merging the entities of the xref to the main drawing, but it will be implemented only in dd 1.13 (version 1.13 has a tentative release date of the end of march, 2005).
if exploding xref inserts with dd >= 1.12.04 produces errors try to use next code as workaround:
code:
//oddbdatabase* pdb; // host database
//oddbobjectid objid; // id of xref block in host database
oddbblocktablerecordptr pblock = oddbblocktablerecord::cast(objid.openobject(oddb::kforwrite));
if (pblock.get() && pblock->isfromexternalreference())
{
odstring path = pblock->pathname();
oddbxrefman::unload(pblock);
oddbxrefman::detach(pblock);
oddbdatabaseptr pxrefdb = pdb->appservices()->readfile(path);
if (pxrefdb.get())
{
pdb->insert(oddbsymutil::blockmodelspacename(), "inserted_xref_block", pxrefdb);
}
}
regards,
sergey vishnevetsky
thanks sergey,
i have a problem that i have multiple instances of each xref (ie the name on the insert is not unique the second time around)
i am using 1.12.04, but can wait for 1.13 as that sounds like a better solution.
thanks for the help,
hugh
|