NX9+VS2012
//NX二次开发中常用拉伸函数为UF_MODL_create_extruded2,但是此函数不能拉伸片体,
//想要拉伸片体用函数UF_MODL_create_extruded。 #include <uf.h>
#include <uf_curve.h>
#include <uf_modl.h>
#include <uf_obj.h> UF_initialize(); //创建直线1
UF_CURVE_line_t LineCoords1;
LineCoords1.start_point[] = 0.0;
LineCoords1.start_point[] = 0.0;
LineCoords1.start_point[] = 0.0;
LineCoords1.end_point[] = 0.0;
LineCoords1.end_point[] = 100.0;
LineCoords1.end_point[] = 0.0;
tag_t LineTag[];
UF_CURVE_create_line(&LineCoords1, &LineTag[]); //创建直线2
UF_CURVE_line_t LineCoords2;
LineCoords2.start_point[] = 0.0;
LineCoords2.start_point[] = 100.0;
LineCoords2.start_point[] = 0.0;
LineCoords2.end_point[] = 100.0;
LineCoords2.end_point[] = 100.0;
LineCoords2.end_point[] = 0.0;
UF_CURVE_create_line(&LineCoords2, &LineTag[]); //创建直线3
UF_CURVE_line_t LineCoords3;
LineCoords3.start_point[] = 100.0;
LineCoords3.start_point[] = 100.0;
LineCoords3.start_point[] = 0.0;
LineCoords3.end_point[] = 100.0;
LineCoords3.end_point[] = 0.0;
LineCoords3.end_point[] = 0.0;
UF_CURVE_create_line(&LineCoords3, &LineTag[]); //创建直线4
UF_CURVE_line_t LineCoords4;
LineCoords4.start_point[] = 100.0;
LineCoords4.start_point[] = 0.0;
LineCoords4.start_point[] = 0.0;
LineCoords4.end_point[] = 0.0;
LineCoords4.end_point[] = 0.0;
LineCoords4.end_point[] = 0.0;
UF_CURVE_create_line(&LineCoords4, &LineTag[]); //创建链表
uf_list_p_t LineList;
UF_MODL_create_list(&LineList); //插入对象到链表
for (int i = ; i < ; i++)
{
UF_MODL_put_list_item(LineList, LineTag[i]);
} //函数1
//创建拉伸(UF_MODL_create_extruded2)
//备注:此函数不能做拉伸片体,只能拉伸封闭的线。拉伸片体用UF_MODL_create_extruded
char *TaperAngle = "0.0";
char *Limit[] = {"0.0", "50.0"};
double Point1[] = {0.0, 0.0, 0.0};
double Direction[] = {0.0, 0.0, 1.0};
UF_FEATURE_SIGN Sign = UF_NULLSIGN;
uf_list_p_t Features1;
UF_MODL_create_extruded2(LineList, TaperAngle, Limit, Point1, Direction, Sign, &Features1); //特征找体
tag_t BodyTag = NULL_TAG;
UF_MODL_ask_feat_body(Features1->eid, &BodyTag); //将拉伸设置成红色
UF_OBJ_set_color(BodyTag,); //释放内存
UF_MODL_delete_list(&LineList); //创建直线
UF_CURVE_line_t LineCoords5;
LineCoords5.start_point[] = 0.0;
LineCoords5.start_point[] = -10.0;
LineCoords5.start_point[] = 0.0;
LineCoords5.end_point[] = 0.0;
LineCoords5.end_point[] = -100.0;
LineCoords5.end_point[] = 0.0;
tag_t LineTag5 = NULL_TAG;
UF_CURVE_create_line(&LineCoords5, &LineTag5); //创建链表
uf_list_p_t LineList1;
UF_MODL_create_list(&LineList1); //插入对象到链表
UF_MODL_put_list_item(LineList1, LineTag5); //函数2
//创建拉伸(UF_MODL_create_extruded)
char *TaperAngle1 = "0.0";
char *Limit1[] = {"0.0", "50.0"};
double Point2[] = {0.0, 0.0, 0.0};
double Direction1[] = {0.0, 0.0, 1.0};
UF_FEATURE_SIGN Sign1 = UF_NULLSIGN;
uf_list_p_t Features2;
UF_MODL_create_extruded(LineList1, TaperAngle1, Limit1, Point2, Direction1, Sign1, &Features2); //特征找体
tag_t BodyTag1 = NULL_TAG;
UF_MODL_ask_feat_body(Features2->eid, &BodyTag1); //将拉伸设置成蓝色
UF_OBJ_set_color(BodyTag1,); //释放内存
UF_MODL_delete_list(&LineList1); UF_terminate();