1 NX11+VS2013 2 3 #include <uf.h> 4 #include <uf_modl.h> 5 #include <uf_ui.h> 6 7 8 UF_initialize(); 9 10 //创建圆柱 11 UF_FEATURE_SIGN Sign = UF_NULLSIGN; 12 double Origin[3] = { 0.0, 0.0, 0.0 }; 13 char *Height1 = "100"; 14 char *Diam1 = "50"; 15 double Direction[3] = { 0.0, 0.0, 1.0 }; 16 tag_t CylTag = NULL_TAG; 17 UF_MODL_create_cyl1(Sign, Origin, Height1, Diam1, Direction, &CylTag); 18 19 20 //获取圆柱的参数 21 char *Diameter;//输出直径 22 char *Height;//输出高度 23 UF_MODL_ask_cylinder_parms(CylTag, 1, &Diameter, &Height); 24 25 26 //打印 27 //默认输出格式为表达式等号左右值 28 UF_UI_open_listing_window(); 29 UF_UI_write_listing_window(Diameter); 30 UF_UI_write_listing_window(" "); 31 UF_UI_write_listing_window(Height); 32 33 34 //只输出表达式等号右值 35 //提取左右值 36 string D = Diameter; 37 string DStrleft = (D.substr(0, D.find("=")));//提取左值 38 string DStrright = (D.substr(D.find("=") + 1, D.find(" ")));//提取右值 39 40 41 string H = Height; 42 string HStrleft = (H.substr(0, H.find("=")));//提取左值 43 string HStrright = (H.substr(H.find("=") + 1, H.find(" ")));//提取右值 44 45 char DBufLeft[256], DBufRight[256];//左值,右值 46 char HBufLeft[256], HBufRight[256];//左值,右值 47 //将string类型转换为字符数组 48 strcpy(DBufLeft, DStrleft.c_str()); 49 strcpy(DBufRight, DStrright.c_str()); 50 51 strcpy(HBufLeft, HStrleft.c_str()); 52 strcpy(HBufRight, HStrright.c_str()); 53 54 //打印右值 55 UF_UI_write_listing_window(" "); 56 UF_UI_write_listing_window(" "); 57 UF_UI_write_listing_window(DBufRight); 58 UF_UI_write_listing_window(" "); 59 UF_UI_write_listing_window(HBufRight); 60 61 62 //释放内存 63 UF_free(Diameter); 64 UF_free(Height); 65 66 UF_terminate();