高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】oddbfcf and explodegeometry and getboundingpoints
oddbfcf and explodegeometry and getboundingpoints
oddbfcf and explodegeometry and getboundingpoints
i have exploded an oddbfcf entity using explodegeometry and i have noticed that the oddbtext entities which result do not handle getboundingpoints properly. all the points (i.e. upper-left and lower-left) are the same.
this seems to happen when escape sequences are used, for instance {\\fgdt;r} explodes to a piece of text with a string of "r" and that one's text returns the unusual bounding points.
a drawing which exhibits this behavior happens to be the one produced by the odwriteex sample.
is there anything i can call which will calculate the extents for these characters?
hello moe,
i can't reproduce your situation. could you explain more detail problem?
here is code which i use for test your problem. possible it will help for you.
code:
oddbcommandcontextptr pdbcmdctx(pcmdctx);
oddbdatabaseptr pdb = pdbcmdctx->database();
oddbuserio* pio = pdbcmdctx->dbuserio();
for ( oddbselectionsetiteratorptr piter = pio->select()->newiterator();
!piter->done(); piter->next() )
{
oddbentityptr pent = oddbentity::cast( piter->objectid().openobject() );
if ( pent.isnull() )
continue;
oddbtextptr text = oddbtext::cast(pent);
if ( text.isnull() )
continue;
odgepoint3darray points;
text->getboundingpoints(points);
odstring msg;
pio->putstring(text->textstring());
msg.format(dd_t("x - %-10.4f y - %-10.4f"), points[0].x, points[0].y);
pio->putstring(msg);
msg.format(dd_t("x - %-10.4f y - %-10.4f"), points[1].x, points[1].y);
pio->putstring(msg);
msg.format(dd_t("x - %-10.4f y - %-10.4f"), points[2].x, points[2].y);
pio->putstring(msg);
msg.format(dd_t("x - %-10.4f y - %-10.4f"), points[3].x, points[3].y);
pio->putstring(msg);
}here is result (
m
x - 21.8575 y - 22.6975
x - 22.1275 y - 22.6975
x - 21.8575 y - 22.4275
x - 22.1275 y - 22.4275
3.2
x - 21.4204 y - 22.6525
x - 21.7804 y - 22.6525
x - 21.4204 y - 22.4725
x - 21.7804 y - 22.4725
n
x - 21.2275 y - 22.6954
x - 21.4075 y - 22.6954
x - 21.2275 y - 22.4254
x - 21.4075 y - 22.4254
r
x - 20.7775 y - 22.6975
x - 21.0475 y - 22.6975
x - 20.7775 y - 22.4275
x - 21.0475 y - 22.4275
best regards,
sergey z.
more info
sergey,
i haven't worked with oddbuserio pointers so i am not sure i understand your example. it looks as if the pio pointer represents an oddbfcf entity which you are iterating through.
however, at the point you have an oddbentityptr which is known to be an oddbfcf entity you might try this:
code:
odrxobjectptrarray::size_type i;
odrxobjectptrarray entities;
odresult res;
odcmcolor clr;
res = pent->explodegeometry(entities);
if ( res == eok )
{
for (i = 0; i < entities.length(); i++)
{
oddbtextptr text = oddbtext::cast(entities[i]);
if ( text.isnull() )
continue;
continue on with getboundingpoints code here
}my results are:
m
x = 21.84029 y = 22.4725
x = 21.84029 y = 22.4725
x = 21.84029 y = 22.4725
x = 21.84029 y = 22.4725
3.2
x = 21.4488 y = 22.65448
x = 21.8124 y = 22.65448
x = 21.4488 y = 22.47052
x = 21.8124 y = 22.47052
n
x = 21.2146 y = 22.4725
x = 21.2146 y = 22.4725
x = 21.2146 y = 22.4725
x = 21.2146 y = 22.4725
r
x = 20.76035 y = 22.4725
x = 20.76035 y = 22.4725
x = 20.76035 y = 22.4725
x = 20.76035 y = 22.4725
i hope this helps and thank you for your efforts so far.
hello moe,
there is strange such behaviour your application. location points of text is right so text extents is calculated correctly during explode. what version of dwgdirect do you use?
best regards,
sergey z.
my version
sergey,
i am working with version 2.4.2.0.
the problem seems only to strike the escape sequences of the feature control frame, whereas the other text, for instance "3.2" in our example, seems fine.
thanks again for taking a look.
- moe -
|