1 #include <uf.h> 2 #include <uf_modl.h> 3 #include <uf_drf.h> 4 #include <uf_obj.h> 5 #include <uf_ui.h> 6 #include <NXOpen/NXObjectManager.hxx> 7 8 9 10 11 Session *theSession = Session::GetSession(); 12 Part *workPart(theSession->Parts()->Work()); 13 Part *displayPart(theSession->Parts()->Display()); 14 15 UF_initialize(); 16 17 //创建表达式 18 tag_t ExpTag = NULL_TAG; 19 UF_MODL_create_exp_tag("A=1", &ExpTag); 20 21 //获得尺寸tag 22 tag_t DimTag = NULL_TAG; 23 UF_OBJ_cycle_by_name("MAIN", &DimTag); 24 25 //创建尺寸表达式抑制 26 UF_DRF_add_controlling_exp(DimTag, ExpTag); 27 28 //获得抑制尺寸的表达式 29 tag_t exp_id = NULL_TAG; 30 UF_DRF_ask_controlling_exp(DimTag, &exp_id); 31 32 //获得表达式的名字 33 Expression *expression1(dynamic_cast<Expression *>(NXOpen::NXObjectManager::Get(exp_id))); 34 NXString ExpName = expression1->Name(); 35 36 //打印 37 char msg[256]; 38 sprintf_s(msg, "%s", ExpName.GetLocaleText()); 39 uc1601(msg,1); 40 41 UF_terminate(); 42 43 Caesar卢尚宇 44 2019年7月17日
这个函数当时做项目一直找不到,最后还是唐工帮我找到的。还是要感谢一下唐工!