[c++] UG二次开发创建旋转C++源代码教程就上UG网

[复制链接]
ug9.0发表于 2016-6-2 07:46:15 | 显示全部楼层 |阅读模式
学NX二次开发就上UG网:
旋转UF函数:UF_MODL_create_revolution(通过对一组线或一条线绕轴旋转成一个实体特征);

UG二次开发

UG二次开发

UG二次开发创建旋转特征C++源码:
  1. #include <malloc.h>
  2. #include <UF_ui.h>
  3. #include <uf_curve.h>
  4. #include <uf_part.h>

  5. #include <uf_csys.h>
  6. #include <stdio.h>
  7. #include <uf.h>
  8. #include <uf_part.h>
  9. #include <uf_curve.h>
  10. #include <uf_csys.h>
  11. #include <uf_defs.h>
  12. #include <uf_obj.h>
  13. #include <uf_layer.h>


  14. /* TODO: Add your application code here */

  15.     /*中磊国际模具培训-创建旋转命令*/
  16.    
  17.     int  obj_count;
  18.     UF_FEATURE_SIGN mode_sign = UF_NULLSIGN;
  19.     tag_t generators[4], line1, line2, line3, line4, *objects;
  20.     char *body_limit[2] = { "0.0", "360.0" };
  21.     char *offsets[2] = { "0.0", "0.0" };
  22.     double origin[3] = { -2.0, 0.0, 0.0 };
  23.     double direction[3] = { 0.0, 1.0, 0.0 };

  24.     UF_MODL_SWEEP_TRIM_object_p_t trim_data = NULL;

  25.     UF_CURVE_line_t sline1, sline2, sline3, sline4;

  26.     /* line#1 */
  27.     sline1.start_point[0] = 0.0;
  28.     sline1.start_point[1] = 0.0;
  29.     sline1.start_point[2] = 0.0;
  30.     sline1.end_point[0] = 0.0;
  31.     sline1.end_point[1] = 1.0;
  32.     sline1.end_point[2] = 0.0;
  33.     UF_CALL(UF_CURVE_create_line(&sline1, &line1));

  34.     /* line#2 */
  35.     sline2.start_point[0] = 0.0;
  36.     sline2.start_point[1] = 1.0;
  37.     sline2.start_point[2] = 0.0;
  38.     sline2.end_point[0] = 2.5;
  39.     sline2.end_point[1] = 3.5;
  40.     sline2.end_point[2] = 0.0;
  41.     UF_CALL(UF_CURVE_create_line(&sline2, &line2));

  42.     /* line#3 */
  43.     sline3.start_point[0] = 2.5;
  44.     sline3.start_point[1] = 3.5;
  45.     sline3.start_point[2] = 0.0;
  46.     sline3.end_point[0] = 1.0;
  47.     sline3.end_point[1] = 0.0;
  48.     sline3.end_point[2] = 0.0;
  49.     UF_CALL(UF_CURVE_create_line(&sline3, &line3));

  50.     /* line#4 */
  51.     sline4.start_point[0] = 1.0;
  52.     sline4.start_point[1] = 0.0;
  53.     sline4.start_point[2] = 0.0;
  54.     sline4.end_point[0] = 0.0;
  55.     sline4.end_point[1] = 0.0;
  56.     sline4.end_point[2] = 0.0;
  57.     UF_CALL(UF_CURVE_create_line(&sline4, &line4));

  58.     generators[0] = line1;
  59.     generators[1] = line2;
  60.     generators[2] = line3;
  61.     generators[3] = line4;

  62.     UF_MODL_create_revolution(generators, 4, trim_data,
  63.         body_limit, offsets, origin, false,
  64.         true, origin, direction, mode_sign,
  65.         &objects, &obj_count);

复制代码



就上UG网淘宝直营店
您需要登录后才可以回帖 登录 | 注册UG网 用百度帐号登录

本版积分规则