之前了解到通过UFUN函数UF_UGMGR_invoke_pdm_server可以调用Teamcenter ITK函数,从而可以获取及编辑Teamcenter对象。UFUN中有样例代码,但是就是不知道怎么使用,今天下午看了帮助文档,想到需要把ITK的USER_invoke_pdm_server函数进行注册,就进行测试,没想到给写通了。在此记录代码调试过程,转载请注明出处。
注意事项:
1-需要了解Teamcenter Handler注册过程。
2-Teamcenter开发方面可以参考微信公众号:PLMCODE
NX工程代码:
1 //================================ 2 // UF_UGMGR_invoke_pdm_server 3 //================================ 4 //tcnx_project 5 6 // Mandatory UF Includes 7 #include <uf.h> 8 #include <uf_object_types.h> 9 #include <uf_draw.h> 10 #include <uf_part.h> 11 #include <uf_ugmgr.h> 12 13 #include <NXSigningResource.cpp> 14 15 // Internal Includes 16 #include <NXOpen/ListingWindow.hxx> 17 #include <NXOpen/NXMessageBox.hxx> 18 #include <NXOpen/UI.hxx> 19 #include <NXOpen/LogFile.hxx> 20 21 // Internal+External Includes\ 22 #include <NXOpen/Annotations.hxx> 23 #include <NXOpen/Assemblies_Component.hxx> 24 #include <NXOpen/Assemblies_ComponentAssembly.hxx> 25 #include <NXOpen/Body.hxx> 26 #include <NXOpen/BodyCollection.hxx> 27 #include <NXOpen/Face.hxx> 28 #include <NXOpen/Line.hxx> 29 #include <NXOpen/NXException.hxx> 30 #include <NXOpen/NXObject.hxx> 31 #include <NXOpen/Part.hxx> 32 #include <NXOpen/PartCollection.hxx> 33 #include <NXOpen/Session.hxx> 34 35 #include <NXOpen/PDM_SoaConnectionHandle.hxx> 36 #include <NXOpen/PDM_PdmSession.hxx> 37 #include <NXOpen/PDM_PdmSearch.hxx> 38 #include <NXOpen/PDM_PdmFile.hxx> 39 #include <NXOpen/PDM_PdmNavigatorNode.hxx> 40 #include <NXOpen/PDM_PdmPart.hxx> 41 #include <NXOpen/PDM_PdmSearchManager.hxx> 42 #include <NXOpen/PDM_SoaQuery.hxx> 43 #include <NXOpen/PDM_SearchResult.hxx> 44 45 #include <NXOpen/PrintPDFBuilder.hxx> 46 #include <NXOpen/PlotManager.hxx> 47 #include <NXOpen/Drawings_DrawingSheet.hxx> 48 #include <NXOpen/NXObjectManager.hxx> 49 50 // Std C++ Includes 51 #include <iostream> 52 #include <sstream> 53 #include <vector> 54 #include <string> 55 #include <algorithm> 56 #include <tchar.h> 57 #include <atlconv.h> 58 #include <shellapi.h> 59 60 #include <windows.h> 61 #undef CreateDialog 62 #pragma comment(lib,"shell32.lib") 63 64 #define CREATION_DATE 1 65 #define MODIFICATION_DATE 2 66 #define MAX_UGMGR_NAME_LEN 1024 67 68 using namespace NXOpen; 69 using std::string; 70 using std::exception; 71 using std::stringstream; 72 using std::endl; 73 using std::cout; 74 using std::cerr; 75 76 NXOpen::ListingWindow *lw = NULL; 77 NXOpen::NXMessageBox *mb = NULL; 78 79 #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X))) 80 int report_error(char *file, int line, char *call, int code) 81 { 82 if (code){ 83 stringstream errmsg; 84 errmsg << "Error " << code << " in " << file << " at line " << line << endl; 85 errmsg << call << endl; 86 cerr << errmsg.str(); 87 throw NXOpen::NXException::Create(code); 88 } 89 return(code); 90 } 91 92 void print(const NXString &); 93 void print