几何尺寸与公差论坛------致力于产品几何量公差标准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)
-   -   【转帖】how to retrive correct order of entities of a block (http://www.dimcax.com/hust/showthread.php?t=16759)

yang686526 2009-05-06 03:10 PM

【转帖】how to retrive correct order of entities of a block
 
how to retrive correct order of entities of a block?
how to retrive correct order of entities of a block?
hi,
i am using dwg 2.2.0.
i have a dimension which text is represented in the dimension block.
i am try to retrive the right order of the entities of the block so that
to show correctly the dimension.
i use newiterator member of oddbblocktablerecord with the sort option but the result it is always a wrong visualization.
can anyone explain how to resume the right order of entities?
here below you can find my code.
thank you in advance.
federico
oddbobjectiteratorptr pentiter = pblock->newiterator(true,true,true);
for (; !pentiter->done(); pentiter->step())
{
oddbobjectptr pent = pentiter->objectid().safeopenobject();
if(!pent.isnull())
{
if(pent->iskindof(oddbtext::desc()))
{
char szbuffer[max_string_len_exchange];
odstring ttext = oddbtextptr(pent)->textstring();
...
...
}
}
newiterator() has 'sorted' parameter. if it's 'true' the iterator returns entities sorted according to block table record's sortents table.
but:
1. dimension blocks usually do not have sortents table.
2. the order of displaying entities from dimension block does not effect the appearence (entities in dimension block do not overlap)
3. dimension block's created by latest autocad and dwgdirect versions contain mtext, not text entities.
sergey slezkin
hi serghey,
thank you very much for your answer.
i think i am making something wrong because i obtain always wrong
order of dimension visualization.
in the attached file some dimensions are typically:
number1 [.number2]
instead the order i receive from block is
number1.number2[]
and it is completelly wrongfor the reader.
i have tried if the enities of teh blcok are oddbmtext but it is not.
i attach here the file.
could you help me?
thank you in advance.
federico
attached files (178.5 kb, 1 views)

1. the file is created by non-autocad application. dimensions store their graphic representation in a block. if you edit somehow a dimension in your file (change color for example) the block is recalculated and text in square brackets disappears. that means that from autocad's point of view dimension style properties do not match the block created by a third-party applicaton.
2. the order of text entities is dimension blocks is not important. each text entitity has it's position which defines the placement of text.
the oder of 4 text entities in dimension blocks is realy:
"number1"
"number2"
"["
"]"
also note that you'll get mtext entities from files created by autocad.
sergey slezkin


所有的时间均为北京时间。 现在的时间是 07:09 PM.