高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】how to get the reference files of a .dwg file
how to get the reference files of a .dwg file?
how to get the reference files of a .dwg file?
hi all,
i'm new to here (actually new to dwgdirect).
could anybody tell me how to get all reference files of a .dwg file using dwgdirect?
thanks a lot.
[ august 14, 2003: message edited by: whatsupmen ]</p>
welcome aboard buddy, you're in for a wild ride.
maybe you can look into "od*db*xref*man"
[ august 14, 2003: message edited by: jeff lambert ]</p>
to get all xrefs referenced by drawing you need to iterate through block table and extract file manes from blocks which are external references.
not that xrefs can be nested.
in autocad 2004 new filedependency functionality was introduced. you can get all file dependecies (xref, image, fonts etc.) with a few lines of code. currently it is not implemented in dd. possibly it will be available in next release.
sergey slezkin
sergey and everyone, how does this look
[code]
// create a database and load the drawing into it.
oddbdatabaseptr pdb;
pdb = svcs.readfile( inpath, false, false, oda::ksharedenyno );
// open the blocks table
oddbblocktableptr pblocks =
pdb->getblocktableid().safeopenobject();
// get an iterator for the block table that skips deleted records
oddbsymboltableiteratorptr pblkiter = pblocks->newiterator();
// for each block in the block table
for (pblkiter->start(); ! pblkiter->done(); pblkiter->step())
{
// open the block
oddbblocktablerecordptr pblock =
pblkiter->getrecordid().safeopenobject();
//check if block is an xref
if (pblock->isdependent())
{
oddbobjectiteratorptr pentiter = pblock->newiterator();
for (; !pentiter->done(); pentiter->step())
{
// get the entity in a pointer
oddbentityptr pent = pentiter->objectid().safeopenobject();
//check if entity is a block reference
if (pent->iskindof(oddbblockreference: :d esc()))
{
//it is a block reference, so get a pointer to it
oddbblockreferenceptr pblockref = pentiter->entity();
//as well as a pointer to its parent
oddbblocktablerecordptr pparentblock = pblockref->blocktablerecord().safeopenobject();
if (pparentblock->pathname())
{
entitycount++;
fprintf(outf,"%s\t%s\n",pblock->getname(), pparentblock->pathname());
}
}
}
}
}
</pre><hr></blockquote>
with the previous code,
if (pblock->isdependent())
never returns true on xref blocks
is there any problems with my code, or is there any other way?
to check if a block table record represents xref drawing oddbblocktablerecord::isfromexternalreference() should be used.
oddbsymboltablerecord::isdependent() returns true if a table record (block, layer, linetype etc.) comes from xref drawing.
so
if (pblock->isfromexternalreference())
{
fprint("...&s...", pblock->pathname());
}
sergey slezkin
i have the similar problem. but i use dwgdirectx in vb.
i can check if a block is a external reference by isxref of iacadblock, and i can get its name. but i cannot find way to get the full path of this external reference file.
probably, i got wrong way.
can you guys help me?
|