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::ValidatorOptions::SaveModeTypesSaveIfPassed); 94 validatorOptions1->SetSaveResultInPart(false); 95 96 // 2023_0328 97 validatorOptions1->SetAutoDisplayResults(Validate::ValidatorOptions::ResultsDisplayModeTypesAlwaysDisplay); 98 validatorOptions1->SetExcludeNonOwnerParts(true); 99 validatorOptions1->SetExcludeReadonlyParts(true); 100 validatorOptions1->SetGenerateCheckFlag(false); 101 validatorOptions1->SetGenerateLogFile(false); 102 validatorOptions1->SetStopOnError(false); 103 validatorOptions1->SetStopOnWarning(false); 104 // 2023_0328 105 106 // Clear part nodes if any. 107 validators1[0]->ClearPartNodes(); 108 109 // Appends the full path of a part file or the current work part. 110 validators1[0]->AppendPartNode(workPart); 111 112 // Manually add this line to clean all existing tests 113 validators1[0]->ClearCheckerNodes(); 114 115 // Select a checker and append it into the Validator object. 116 std::vector<NXString> classnames1(2); 117 classnames1[0] = "%mqc_report_browseable_features";//mqc_profile_modeling_cn.dfa 118 classnames1[1] = "%mqc_profile_modeling_cn";//mqc_profile_modeling_cn.dfa 119 validators1[0]->AppendCheckerNodes(classnames1); 120 121 // Execute the Check-Mate checker. 122 Validation::Result status1; 123 status1 = validators1[0]->Commit(); 124 125 // Get a Parser object, and show the checker result. 126 std::vector<Validate::Parser *> parsers1; 127 theSession->ValidationManager()->FindParser("Validation Gadget", parsers1); 128 parsers1[0]->ClearResultObjects(); 129 parsers1[0]->SetDataSource(Validate::Parser::DataSourceTypesMostRecentRun); 130 parsers1[0]->SetMaxDisplayObjects(10); 131 parsers1[0]->Commit(); 132 133 return 0; 134 }
設定、保存后、用戶默認設定截圖:




除錯GIF動態圖:

黃河遠上白云間,一片孤城萬仞山,
羌笛何須怨楊柳,春風不度玉門關,
詩人初到涼州,面對黃河、邊城的遼闊景象,又耳聽著《折楊柳》曲,有感而發,寫成了這首表現戍守邊疆的士兵思念家鄉情懷的詩作,
詩的前兩句描繪了西北邊地廣漠壯闊的風光,首句抓住自下(游)向上(游)、由近及遠眺望黃河的特殊感受,描繪出“黃河遠上白云間”的動人畫面:洶涌澎湃波浪滔滔的黃河竟像一條絲帶迤邐飛上云端,寫得真是神思飛躍,氣象開闊,詩人的另一名句“黃河入海流”,其觀察角度與此正好相反,是自上而下的目送;而李白的“黃河之水天上來”,雖也寫觀望上游,但視線運動卻又由遠及近,與此句不同,“黃河入海流”和“黃河之水天上來”,同是著意渲染黃河一瀉千里的氣派,表現的是動態美,而“黃河遠上白云間”,方向與河的流向相反,意在突出其源遠流長的閑遠儀態,表現的是一種靜態美,同時展示了邊地廣漠壯闊的風光,不愧為千古奇句,
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/548546.html
標籤:C++
上一篇:【Visual Leak Detector】配置項 StackWalkMethod
下一篇:QML和QT
