NX二次开发-UFUN拉伸函数UF_MODL_create_extruded2

  1     NX9+VS2012
  2     //NX二次开发中常用拉伸函数为UF_MODL_create_extruded2,但是此函数不能拉伸片体,
  3     //想要拉伸片体用函数UF_MODL_create_extruded。
  4     
  5     #include <uf.h>
  6     #include <uf_curve.h>
  7     #include <uf_modl.h>
  8     #include <uf_obj.h>
  9 
 10 
 11     UF_initialize();
 12 
 13     //创建直线1
 14     UF_CURVE_line_t LineCoords1;
 15     LineCoords1.start_point[0] = 0.0;
 16     LineCoords1.start_point[1] = 0.0;
 17     LineCoords1.start_point[2] = 0.0;
 18     LineCoords1.end_point[0] = 0.0;
 19     LineCoords1.end_point[1] = 100.0;
 20     LineCoords1.end_point[2] = 0.0;
 21     tag_t LineTag[4];
 22     UF_CURVE_create_line(&LineCoords1, &LineTag[0]);
 23 
 24     //创建直线2
 25     UF_CURVE_line_t LineCoords2;
 26     LineCoords2.start_point[0] = 0.0;
 27     LineCoords2.start_point[1] = 100.0;
 28     LineCoords2.start_point[2] = 0.0;
 29     LineCoords2.end_point[0] = 100.0;
 30     LineCoords2.end_point[1] = 100.0;
 31     LineCoords2.end_point[2] = 0.0;
 32     UF_CURVE_create_line(&LineCoords2, &LineTag[1]);
 33 
 34     //创建直线3
 35     UF_CURVE_line_t LineCoords3;
 36     LineCoords3.start_point[0] = 100.0;
 37     LineCoords3.start_point[1] = 100.0;
 38     LineCoords3.start_point[2] = 0.0;
 39     LineCoords3.end_point[0] = 100.0;
 40     LineCoords3.end_point[1] = 0.0;
 41     LineCoords3.end_point[2] = 0.0;
 42     UF_CURVE_create_line(&LineCoords3, &LineTag[2]);
 43 
 44     //创建直线4
 45     UF_CURVE_line_t LineCoords4;
 46     LineCoords4.start_point[0] = 100.0;
 47     LineCoords4.start_point[1] = 0.0;
 48     LineCoords4.start_point[2] = 0.0;
 49     LineCoords4.end_point[0] = 0.0;
 50     LineCoords4.end_point[1] = 0.0;
 51     LineCoords4.end_point[2] = 0.0;
 52     UF_CURVE_create_line(&LineCoords4, &LineTag[3]);
 53     
 54     //创建链表
 55     uf_list_p_t LineList;
 56     UF_MODL_create_list(&LineList);
 57 
 58     //插入对象到链表
 59     for (int i = 0; i < 4; i++)
 60     {
 61         UF_MODL_put_list_item(LineList, LineTag[i]);
 62     }
 63     
 64     //函数1
 65     //创建拉伸(UF_MODL_create_extruded2)
 66     //备注:此函数不能做拉伸片体,只能拉伸封闭的线。拉伸片体用UF_MODL_create_extruded
 67     char *TaperAngle = "0.0";
 68     char *Limit[2] = {"0.0", "50.0"};
 69     double Point1[3] = {0.0, 0.0, 0.0};
 70     double Direction[3] = {0.0, 0.0, 1.0};
 71     UF_FEATURE_SIGN Sign = UF_NULLSIGN;
 72     uf_list_p_t Features1;
 73     UF_MODL_create_extruded2(LineList, TaperAngle, Limit, Point1, Direction, Sign, &Features1);
 74 
 75     //特征找体
 76     tag_t BodyTag = NULL_TAG;
 77     UF_MODL_ask_feat_body(Features1->eid, &BodyTag);
 78 
 79     //将拉伸设置成红色
 80     UF_OBJ_set_color(BodyTag,186);
 81 
 82     //释放内存
 83     UF_MODL_delete_list(&LineList);
 84 
 85     //创建直线
 86     UF_CURVE_line_t LineCoords5;
 87     LineCoords5.start_point[0] = 0.0;
 88     LineCoords5.start_point[1] = -10.0;
 89     LineCoords5.start_point[2] = 0.0;
 90     LineCoords5.end_point[0] = 0.0;
 91     LineCoords5.end_point[1] = -100.0;
 92     LineCoords5.end_point[2] = 0.0;
 93     tag_t LineTag5 = NULL_TAG;
 94     UF_CURVE_create_line(&LineCoords5, &LineTag5);
 95 
 96     //创建链表
 97     uf_list_p_t LineList1;
 98     UF_MODL_create_list(&LineList1);
 99 
100     //插入对象到链表
101     UF_MODL_put_list_item(LineList1, LineTag5);
102 
103 
104     //函数2
105     //创建拉伸(UF_MODL_create_extruded)
106     char *TaperAngle1 = "0.0";
107     char *Limit1[2] = {"0.0", "50.0"};
108     double Point2[3] = {0.0, 0.0, 0.0};
109     double Direction1[3] = {0.0, 0.0, 1.0};
110     UF_FEATURE_SIGN Sign1 = UF_NULLSIGN;
111     uf_list_p_t Features2;
112     UF_MODL_create_extruded(LineList1, TaperAngle1, Limit1, Point2, Direction1, Sign1, &Features2);
113 
114     //特征找体
115     tag_t BodyTag1 = NULL_TAG;
116     UF_MODL_ask_feat_body(Features2->eid, &BodyTag1);
117 
118     //将拉伸设置成蓝色
119     UF_OBJ_set_color(BodyTag1,211);
120 
121     //释放内存
122     UF_MODL_delete_list(&LineList1);
123 
124     UF_terminate();

原文地址:https://www.cnblogs.com/nxopen2018/p/10975861.html