设为首页 加入收藏

TOP

NX二次开发:Checkmate例子根据dfa文件检查模型数据(一)
2023-07-23 13:34:19 】 浏览:53
Tags:Checkmate dfa 文件检 查模型

NX中的checkmate功能是用于检查模型、图纸数据的工具,在UGOPEN中有例子。手动操作可以检查已加载的装配下所有零部件,可以设置通过后保存模型,检查结果保存到Teamcenter中,默认保存在零组件版本下。

代码中可以设置多个检查规则。相关设置可以在用户默认设置中进行设置。

  1 //=============================
  2 // Checkmate例子
  3 //=============================
  4 // Mandatory UF Includes
  5 #include <uf.h>
  6 #include <uf_object_types.h>
  7 #include <uf_draw.h>
  8 #include <uf_part.h>
  9 #include <uf_ugmgr.h>
 10 #include <uf_ui.h>
 11 #include <uf_obj.h>
 12 #include <uf_drf.h>
 13 
 14 // Std C++ Includes
 15 #include <iostream>
 16 #include <sstream>
 17 #include <vector>
 18 #include <string>
 19 #include <algorithm>
 20 #include <tchar.h>
 21 #include <atlconv.h>
 22 #include <shellapi.h>
 23 
 24 // check mate
 25 #include <NXOpen/Validate_ValidationManager.hxx>
 26 #include <NXOpen/Validate_Validator.hxx>
 27 #include <NXOpen/Validate_ValidatorOptions.hxx>
 28 #include <NXOpen/Validate_Parser.hxx>
 29 
 30 #include <windows.h>
 31 #undef CreateDialog
 32 #pragma comment(lib,"shell32.lib")
 33 
 34 using namespace NXOpen;
 35 using std::string;
 36 using std::exception;
 37 using std::stringstream;
 38 using std::endl;
 39 using std::cout;
 40 using std::cerr;
 41 
 42 int ExecuteCheckerAndGetResults();
 43 
 44 extern "C" DllExport void ufusr( char *parm, int *returnCode, int rlen )
 45 {
 46     try
 47     {
 48         UF_CALL(UF_initialize());
 49 
 50         ExecuteCheckerAndGetResults();
 51 
 52         UF_CALL(UF_terminate());
 53     }
 54     catch (const NXException& e1)
 55     {
 56         UI::GetUI()->NXMessageBox()->Show("NXException", NXOpen::NXMessageBox::DialogTypeError, e1.Message());
 57     }
 58     catch (const exception& e2)
 59     {
 60         UI::GetUI()->NXMessageBox()->Show("Exception", NXOpen::NXMessageBox::DialogTypeError, e2.what());
 61     }
 62     catch (...)
 63     {
 64         UI::GetUI()->NXMessageBox()->Show("Exception", NXOpen::NXMessageBox::DialogTypeError, "Unknown Exception.");
 65     }
 66 }
 67 
 68 extern "C" DllExport int ufusr_ask_unload()
 69 {
 70     return (int)NXOpen::Session::LibraryUnloadOptionImmediately;// 调试用
 71     //return (int)NXOpen::Session::LibraryUnloadOptionAtTermination;// 程序发布用
 72     //return (int)NXOpen::Session::LibraryUnloadOptionExplicitly;
 73 }
 74 
 75 int ExecuteCheckerAndGetResults()
 76 { 
 77     // Get the NX session, work part, display part.
 78     Session *theSession = Session::GetSession();
 79     Part *workPart(theSession->Parts()->Work());
 80     Part *displayPart(theSession->Parts()->Display());
 81 
 82     // Get the NX Check-Mate Validator object.
 83     std::vector<Validate::Validator *> validators1;
 84     theSession->ValidationManager()->FindValidator("Check-Mate", validators1);
 85 
 86     // Get the NX Check-Mate ValidatorOptions, and set options.
 87     Validate::ValidatorOptions *validatorOptions1;
 88     validatorOptions1 = validators1[0]->ValidatorOptions();
 89 
 90     validatorOptions1->SetSkipChecking(false);
 91     validatorOptions1->SetSkipCheckingDontLoadPart(false);
 92     validatorOptions1->SetSaveResultInTeamcenter(Validate::ValidatorOptions::SaveModeTypesSaveIfPassed);
 93     validatorOptions1->SetSavePartFile(Validate::Valid
首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇关于scanf函数不能在某些vs编译器.. 下一篇<六>指向类成员的指针

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目