几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » AutoCAD二次开发 » DirectDWG
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


回复
 
主题工具 搜索本主题 显示模式
旧 2009-05-06, 02:45 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】how to get the extent of a text string in dwgdirec

how to get the extent of a text string in dwgdirect?
how to get the extent of a text string in dwgdirect?
in arx, we can get the extent of a text string by acgitextstyle::extents function. but in dwgdirect, the odgitextstyle class don't have a similar one;
i tried to calculate the text string extent with the od*gi*fast*ext*calc class,
but cann't create an instance of this class.
the following is the introduction of fuctiong extents in arx;
virtual acgepoint2d extents(const char* pstr, const adesk::boolean penups,
const int len, const adesk::boolean raw,
acgiworlddraw * ctxt = null) const;
pstr input a pointer to a text string for which the extents are to be determined
penups input boolean indicating if leading and trailing spaces are to be included
len input text string length or -1 to indicate null-terminated string
raw input boolean indicating if the autocad escape sequences are to be interpreted
ctxt input pointer to acgiworlddraw; if null, the autocad default regen pipeline is used to calculate extents
this function provides the means to find out the extents of the text string pstr when using the acgitextstyle.
if penups is adesk::ktrue, then any leading and trailing spaces is included in the extents calculation.
a value of -1 for len indicates that the string is null-terminated. any other value is interpreted as the length of the string pointed to by pstr and only that many characters are used. len must not be larger than the length of the string.
if raw is adesk::ktrue, then any autocad escape sequences in the string (such as %%u, %%d, %%p, and %%nnn) are left as is and not interpreted.
note in object dbx, you must create a valid acgiworlddraw and pass it in to this function in the ctxt argument for the extent calculation to work.
the returned acgepoint2d contains the text's extents. the x member is the width of the text, the y is the height.
thanks;
quote:
originally posted by ccli
i tried to calculate the text string extent with the od*gi*fast*ext*calc class,
but cann't create an instance of this class.
try to use next code
code:
odstaticrxobject<odgifastextcalc> drawobj;
odstaticrxobject<odgicontextfordbdatabase> gicontext;
drawobj.setcontext(&gicontext);
drawobj.text(...);
odgeextents3d extents;
drawobj.getextents(extents);
best regards,
sergey z.
thank you very much!
i have got the text extents with your recommended codes;
but there is another question, i cann't set the scale of x axis!
the scale which is setted by the setxscale function, has no effect with
the text extent; the following is the code;
odgitextstyle textstyle;
odgeextents3d textextents;
odstaticrxobject<odgifastextcalc> drawobj;
odstaticrxobject<odgicontextfordbdatabase> gicontext;
drawobj.setcontext(&gicontext);
textstyle.setxscale(textstyle.xscale() * (dwidth / dactwidth));
drawobj.text(ptpos,odgevector3d::kzaxis,odgevector 3d::kxaxis,
lpctstr(stext),-1, false,&textstyle);
drawobj.getextents(textextents);
ptsize.x = textextents.maxpoint().x - textextents.minpoint().x;
ptsize.y = textextents.maxpoint().y - textextents.minpoint().y;
thanks;
quote:
originally posted by ccli
but there is another question, i cann't set the scale of x axis!
the scale which is setted by the setxscale function, has no effect with
the text extent; the following is the code;
are you sure what (dwidth / dactwidth) is not equal 1.0?
i try to call textstyle.setxscale(2.0) and (textextents.maxpoint().x - textextents.minpoint().x) value is changed ( x 2.0 as compared with xscale 1.0 ).
best regards,
sergey z.
quote:
originally posted by sergey z.
are you sure what (dwidth / dactwidth) is not equal 1.0?
i try to call textstyle.setxscale(2.0) and (textextents.maxpoint().x - textextents.minpoint().x) value is changed ( x 2.0 as compared with xscale 1.0 ).
yes,i'm sure. in my aplication, what (dwidth / dactwidth) is less than 1.0;
at last, i solved this problem with:
ptsize.x = textextents.maxpoint().x - textextents.minpoint().x;
ptsize.x = ptsize.x * textstyle.xscale();
thanks.
hello,
you need call drawobj.resetextents() befor second call calculate extents (drawobj.text(..)).
best regards,
sergey z.
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】how do i recognize an overridden fon yang686526 DirectDWG 0 2009-05-05 12:29 PM
【转帖】哪位高手指点一下下边lisp的怎么用 yang686526 数据库ObjectDBX 0 2009-04-28 12:13 PM
哪位高手指点一下下边lisp的怎么用 yang686526 ObjectARX(AutoLISP) 0 2009-04-26 06:19 PM
【转帖】ado.net access操作方法 yang686526 ObjectARX(VB.NET/C#) 0 2009-04-19 09:37 PM
【转帖】custom properties for multiple part configurations yang686526 SolidWorks二次开发 0 2009-04-13 10:08 AM


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


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多