NX二次开发-UFUN添加工程图投影视图UF_DRAW_add_orthographic_view

时间:2021-01-17 19:20:49
 NX9+VS2012

 #include <uf.h>
#include <uf_draw.h>
#include <uf_obj.h>
#include <uf_part.h> UF_initialize(); //新建工程图(A4图纸)
char* DrawingName = "Sheet1";//设置图纸名字
UF_DRAW_info_t DrawingInfo;//设置图纸大小、投影视角、视图比例等
DrawingInfo.size_state = UF_DRAW_METRIC_SIZE;//设置图纸类型
DrawingInfo.size.metric_size_code = UF_DRAW_A4;//设置图纸大小
DrawingInfo.drawing_scale = 1.0;//设置比例
DrawingInfo.units = UF_PART_METRIC;//设置单位
DrawingInfo.projection_angle = UF_DRAW_FIRST_ANGLE_PROJECTION;//设置投影视角
tag_t DrawingTag = NULL_TAG;
UF_DRAW_create_drawing(DrawingName, &DrawingInfo, &DrawingTag); //导入视图(创建Top视图)
//找名字获取视图的Tag
tag_t TopViewTag = NULL_TAG;
UF_OBJ_cycle_by_name_and_type(UF_PART_ask_display_part(), "Top", UF_view_type, false, &TopViewTag); UF_DRAW_view_info_t TopViewInfo;
UF_DRAW_initialize_view_info(&TopViewInfo);//初始化视图信息
double TopDwgPoint[] = {150.0, 160.0};
tag_t TopDrawViewTag = NULL_TAG;
UF_DRAW_import_view(DrawingTag, TopViewTag, TopDwgPoint, &TopViewInfo, &TopDrawViewTag); //添加投影视图
//UF_DRAW_project_infer = 0,自动判断
//UF_DRAW_project_above,上
//UF_DRAW_project_right,右
//UF_DRAW_project_below,下
//UF_DRAW_project_left左
UF_DRAW_proj_dir_t RightProjection = UF_DRAW_project_right;
double RightDwgPoint[] = {35.0, 160.0};
tag_t RightViewTag = NULL_TAG;
UF_DRAW_add_orthographic_view(DrawingTag, TopDrawViewTag, RightProjection, RightDwgPoint, &RightViewTag); //更新视图
UF_DRAW_update_one_view(DrawingTag, TopDrawViewTag);
UF_DRAW_update_one_view(DrawingTag, RightViewTag); UF_terminate();

NX二次开发-UFUN添加工程图投影视图UF_DRAW_add_orthographic_view