UG爱好者

标题: UG/Open API获取用户输入实例 [打印本页]

作者: 2847657989    时间: 2014-3-18 22:42
标题: UG/Open API获取用户输入实例

UG/Open API的用户界面接口通过大量的子过程显示提示信息、接收信息及菜单,并等候用户应答。这些子过程是uc1600~uc1613,这些提示信息被显示在UG主界面的暗示行,一般说来,暗示行允许显示80个字符,但还依赖于所使用的字体。下面简单介绍部分函数的功能及其使用方法。
(1)函数uc1600():用于获取用户的字符串输入。
(2)函数uc1607():显示键盘输入界面并获取整数输入,返回值及参数说明如下。
 1:回退。
 2:取消。
 3:接收(无用户输入时)。
 4:接收(有用户输入时)。
 8:不允许状态,不能启动对话框。
(3)函数uc1608():显示键盘输入菜单界面并获取整型或实型输入,返回值及参数说明等同于函数uc1607()。
(4)函数uc1609():显示键盘输入对话框并获取实型数,该函数与uc1607()类似。
(5)函数uc1613():显示键盘输入菜单,并获取整型、实型及字符串数据,该函数与uc1608()类似。
下面的例子来说明函数uc1609的使用方法:
UF_PART_ask_display_part,用于查询当前显示的part文件;
函数UF_MODL_create_exp用于创建表达式;
函数UF_MODL_edit_exp用于修改表达式。
创建获取用户输入的对话框。

  1. #include <string.h>
  2. #include <math.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <uf_defs.h>
  6. #include <uf_curve.h>
  7. #include <uf_modl.h>
  8. #include <uf_part.h>char *cp1 = "CUTTER DATA";
  9. char cp2[][16]={"Diameter", "Cut Length", "Flute Blade" };
  10. int ir6, ip3 = 3 ;
  11. double tool_data[] = { 3, 3, 1 };
  12. int ip5[] = { 6,6,6 };
  13. char dia[20], cut[20], flute[20], tmp[20];
  14. int actprt;
  15. ir6 = uc1609( cp1, cp2, ip3, tool_data, ip5 );
  16. strcpy(dia,"dia=");
  17. sprintf(tmp,"%f",tool_data[0]);
  18. strcat(dia, tmp);
  19. strcpy(cut,"cut=");
  20. sprintf(tmp,"%f",tool_data[1]);
  21. strcat(cut, tmp);
  22. strcpy(flute,"flute=");
  23. sprintf(tmp,"%f",tool_data[2]);
  24. strcat(flute, tmp);
  25. actprt = UF_PART_ask_display_part(); /* check if active part */
  26. if( actprt != NULL_TAG)
  27. { ir6 = UF_MODL_create_exp(dia);
  28. if( ir6 != 0) ir6=UF_MODL_edit_exp(dia);
  29. ir6 = UF_MODL_create_exp(cut);
  30. if( ir6 != 0) ir6=UF_MODL_edit_exp(cut);
  31. ir6 = UF_MODL_create_exp(flute);
  32. if( ir6 != 0) ir6=UF_MODL_edit_exp(flute);}
复制代码


作者: 副总经理    时间: 2014-3-18 23:06
非常感谢楼主的分享。
作者: 火烨110*    时间: 2014-3-18 23:38
没看懂 还是要支持的
作者: 惊弓之鸟    时间: 2015-10-7 14:04
做个标记,顶上去




欢迎光临 UG爱好者 (https://www.ugsnx.com/) Powered by Discuz! X3.2