高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】odd behavior concerning nested references
odd behavior concerning nested references.
odd behavior concerning nested references.
i have noticed some peculiar behavior with some code i have written pertaining to references and nested references. i have attached two sets of files in one zip file. when opened in adt 3.3, they look identical as far as the reference attachments. however, when ran through my dll using open design, the external references returned are different. in one set, i can see "all the way to the bottom" of the reference chain (1.dwg->2.dwg->3.dwg) although they appear to be nested and you would think that i could only see 2.dwg when looking at 1.dwg with opendesign. in the other set, if i analyze 1.dwg, i can only see 2.dwg as you would expect. i have used an objectarx debug utility to see some of the properties of the block record as adt sees it and they look identical in both cases.
after further analysis, it seems like it depends on the order in which the references were attached. if i first attached 1 to 2, then 2 to 3 it would act as you would expect. if you attached 2 to 3 then 1 to 2, then i can see all of them by looking at 1.
so the question is, can someone tell me what the hell is going on here?
i have also included in the zip file, a test app and the dll i wrote. you simply input the whole path to the file in the text box and press the button. a messagebox will appear with the references and rasters found. the number code after the path distiguishes the type. 0-overlay 1-attachment 2-raster. a chunk of the code for the dll is in the code.txt file.
i understand if my explanation is a bit confusing.
if you don't see what i am saying, let me know and i will try to explain it more clearly.
edit: it turns out i can't post a file that big. the big one is the dll.
if someone wants me to email it to them, i will. otherwise i will need
to host it somewhere else.
attached files
another interesting effect that semi-explains the behavior i am describing
in the post above.
if i open 1.dwg from the set that i can only see 2.dwg with my dll in adt 3.3 and then save the drawing. then the dll reports 2 and 3 back to me.
so, it seems that once references are resolved in autocad/adt once,
the file is aware of the nested references for that file and they are
available in that file from then on.
is there any call that would tell me that a reference found for a file
is from another reference?
i can't see an obvious one.
oddbsymboltablerecord::isdependent() returns true for table records which come from external references. if it returns true for block table record it means that the block is from external reference. if the block is external reference itself - it's nested xref.
sergey slezkin
quote:
originally posted by sergey slezkin
oddbsymboltablerecord::isdependent() returns true for table records which come from external references. if it returns true for block table record it means that the block is from external reference. if the block is external reference itself - it's nested xref.
so isfromexternalreference() && !isdependent() should return references that aren't nested? that's not the behavior i am seeing. isdependent is not returning true for any block table record, nevermind the ones that are from external references.
i tried this in arx and the behavior is identical for the block table.
what am i missing here?
sorry, i was wrong about isdependent().
you can use oddbxrefgraph class.
see example of its usage in odamfcapp sample (xrefviewdlg.cpp)
you can see how it works in odamfcapp if you select insert/xref manager and click graph button at upper left corner of the dialog.
sergey slezkin
thanks for the reply. i see what they are doing using the xrefgraph
and that works out well. here is the code i have written for everyone
else's reference. the function that contains this code returns a delimited string with reference info.
//get the xrefgraph from the loaded database
oddbxrefgraph::getfrom(pdb, m_graph);
n = m_graph.numnodes();
for(int i=0; i<n; ++i)
{
oddbxrefgraphnode* pnode = m_graph.xrefnode(i);
if(pnode!=m_graph.rootnode())
{
oddbblocktablerecordptr pxrefblock = pnode->blockid().safeopenobject();
if (!pnode->isnested()) { //we don't want to get the nested references.
if (pxrefblock->isfromoverlayreference()) {
strcat(inbuf,pxrefblock->pathname());
strcat(inbuf,delimiter);
strcat(inbuf,"0");
strcat(inbuf,delimiter);
}
else {
strcat(inbuf,pxrefblock->pathname());
strcat(inbuf,delimiter);
strcat(inbuf,"1");
strcat(inbuf,delimiter);
}
}
}
}
|