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

yang686526 2009-05-05 09:30 AM

【转帖】entity type
 
entity type
entity type
is there an a better way to find the entity type without using a string compare?
odstring entitytype;
entitytype = pent->isa()->name();
if (0 == stricmp(entitytype, "acdbline"))
{
}
else if (0 == stricmp(entitytype, "acdbarc"))
{
}
...
in the old libraries you could use a switch statement:
switch (adenhd->enttype)
{
case ad_ent_line:
break;
case ad_ent_arc:
break;
...
}
you can also use iskindof(), isderivedfrom() methods.
but the most efficient way to replace old style "switch" statement is using protocol extensions (see odreadex sample).
sergey slezkin
can the desc() method help in this way (because sometimes on simple lines of code the protocol extensions can be more difficult to implement).
i.e.:
switch(pent->isa()) {
case(oddbline::desc()) : {}
case(oddbarc::desc()) : {}
}
regards
chudomir
is this correct? the case statements need to be constant expressions. how do you resolve this?
case (oddbline::desc()): {}
yes - use if else
if( f ( obj->iskindof(oddbmtext::desc()) ) {
...
} else if ( obj->iskindof(oddbfcf::desc()) )
...
} else if ( obj->iskindof(oddbblockreference::desc()) )
...
} else if ( obj->iskindof(oddbleader::desc()) )
...
} else if ( obj->iskindof(oddbarc::desc()) )
ect...
thank you


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