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

yang686526 2009-05-07 12:34 PM

【转帖】reading mtext blob and or te
 
reading mtext blob and / or text
reading mtext blob and / or text
included are two samples of code, the first one being our old code, and the second one being our new code. i haven't seen anything related to blobs in the dwgdirect documentation. i am sure contents() outputs stuff when it's just one line of text but what happens if it contains a blob? i am looking for examples of code.
also is there a better way to determine the class of an entity or is that it? (pent->isa()->name())
[code]
//old code
if (madenhd->enttype == ad_ent_mtext)
{
if (maden->mtext.ldblob == ad_vmnull)
fprintf(outf,"\n%s",maden->mtext.textstr);
else
{
pad_blob_ctrl bcptr = adstartblobread(maden->mtext.ldblob);
while (adreadmtextblock(bcptr,maden->mtext.textstr))
fprintf(outf,"\n%s",maden->mtext.textstr);
}
}
</pre><hr></blockquote>
[code]
//new code
if (pent-&gt;isa()-&gt;name() == "acdbmtext")
{
//cast entity as mtext pointer
oddbmtextptr pmtext = pentiter-&gt;entity();
//print out the contents
//but might be missing stuff, compare to old code
fprintf(outf,"\n%s",pmtext-&gt;contents());
}
</pre><hr></blockquote>

using odt you have to look at textstr or blob to get the contents of mtext (depending on text string length).
using dwgdirect you always get mtext contents by the contents() method.
entity type.
some other methods:
oddbentityptr pent = ...
if (pent-&gt;isa() == oddbmtext: esc())
{ // this entity is mtext
}
oddbmtextptr pmtext = oddbmtext::cast(pent);
if (!pmtext.isnull())
{ // this entity is mtext
}
if your applicaion needs not only mtext processing but some kind of switch on entity type the most effective method is using protocol extensions.
sergey slezkin

thank you for your answers. i have tried using protocol extensions but found it very hard to implement, even with the example. i don't need a huge switch or in-depth class-specific functionality, so comparing entities to class names will do for now.
thanks again.


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