1 NX9+VS2012 2 3 #include <uf.h> 4 #include <uf_draw.h> 5 #include <uf_obj.h> 6 #include <uf_part.h> 7 8 UF_initialize(); 9 10 //新建工程图(A4图纸) 11 char* DrawingName = "Sheet1";//设置图纸名字 12 UF_DRAW_info_t DrawingInfo;//设置图纸大小、投影视角、视图比例等 13 DrawingInfo.size_state = UF_DRAW_METRIC_SIZE;//设置图纸类型 14 DrawingInfo.size.metric_size_code = UF_DRAW_A4;//设置图纸大小 15 DrawingInfo.drawing_scale = 1.0;//设置比例 16 DrawingInfo.units = UF_PART_METRIC;//设置单位 17 DrawingInfo.projection_angle = UF_DRAW_FIRST_ANGLE_PROJECTION;//设置投影视角 18 tag_t DrawingTag = NULL_TAG; 19 UF_DRAW_create_drawing(DrawingName, &DrawingInfo, &DrawingTag); 20 21 //导入视图(创建Top视图) 22 //找名字获取视图的Tag 23 tag_t TopViewTag = NULL_TAG; 24 UF_OBJ_cycle_by_name_and_type(UF_PART_ask_display_part(), "Top", UF_view_type, false, &TopViewTag); 25 26 UF_DRAW_view_info_t TopViewInfo; 27 UF_DRAW_initialize_view_info(&TopViewInfo);//初始化视图信息 28 double TopDwgPoint[2] = {150.0, 160.0}; 29 tag_t TopDrawViewTag = NULL_TAG; 30 UF_DRAW_import_view(DrawingTag, TopViewTag, TopDwgPoint, &TopViewInfo, &TopDrawViewTag); 31 32 //添加投影视图 33 //UF_DRAW_project_infer = 0,自动判断 34 //UF_DRAW_project_above,上 35 //UF_DRAW_project_right,右 36 //UF_DRAW_project_below,下 37 //UF_DRAW_project_left左 38 UF_DRAW_proj_dir_t RightProjection = UF_DRAW_project_right; 39 double RightDwgPoint[2] = {35.0, 160.0}; 40 tag_t RightViewTag = NULL_TAG; 41 UF_DRAW_add_orthographic_view(DrawingTag, TopDrawViewTag, RightProjection, RightDwgPoint, &RightViewTag); 42 43 //视图重命名 44 Drawings::BaseView *baseView1(dynamic_cast<Drawings::BaseView *>(NXOpen::NXObjectManager::Get(TopDrawViewTag))); 45 baseView1->SetName("LSY"); 46 47 //更新视图 48 UF_DRAW_update_one_view(DrawingTag, TopDrawViewTag); 49 UF_DRAW_update_one_view(DrawingTag, RightViewTag); 50 51 UF_terminate();