设为首页 加入收藏

TOP

Teamcenter_NX集成开发:通过NXOpen查询零组件是否存在(一)
2023-07-23 13:35:01 】 浏览:78
Tags:Teamcenter_NX 成开发 通过 NXOpen 查询零

之前用过NXOpen PDM的命名空间下的类,现在记录一下通过PDM命名空间下的类查询Teamcenter零组件的信息,也可以用来判断该零组件是否存在。

1-该工程为DLL工程,直接在NX界面调用,所以直接获取NXSession。

2-查询函数advanced用到的查询为:__NX_STD_ANY_ITEM_QUERY,可以在Teamcenter查询构建器模块中看到该查询。

 

  1 // Mandatory UF Includes
  2 #include <uf.h>
  3 #include <uf_object_types.h>
  4 
  5 // Internal Includes
  6 #include <NXOpen/ListingWindow.hxx>
  7 #include <NXOpen/NXMessageBox.hxx>
  8 #include <NXOpen/UI.hxx>
  9 #include <NXOpen/LogFile.hxx>
 10 
 11 // Internal+External Includes
 12 #include <NXOpen/Annotations.hxx>
 13 #include <NXOpen/Assemblies_Component.hxx>
 14 #include <NXOpen/Assemblies_ComponentAssembly.hxx>
 15 #include <NXOpen/Body.hxx>
 16 #include <NXOpen/BodyCollection.hxx>
 17 #include <NXOpen/Face.hxx>
 18 #include <NXOpen/Line.hxx>
 19 #include <NXOpen/NXException.hxx>
 20 #include <NXOpen/NXObject.hxx>
 21 #include <NXOpen/Part.hxx>
 22 #include <NXOpen/PartCollection.hxx>
 23 #include <NXOpen/Session.hxx>
 24 
 25 #include <NXOpen/PDM_SoaConnectionHandle.hxx>
 26 #include <NXOpen/PDM_PdmSession.hxx>
 27 #include <NXOpen/PDM_PdmSearch.hxx>
 28 #include <NXOpen/PDM_PdmFile.hxx>
 29 #include <NXOpen/PDM_PdmNavigatorNode.hxx>
 30 #include <NXOpen/PDM_PdmPart.hxx>
 31 #include <NXOpen/PDM_PdmSearchManager.hxx>
 32 #include <NXOpen/PDM_SoaQuery.hxx>
 33 #include <NXOpen/PDM_SearchResult.hxx>
 34 
 35 // Std C++ Includes
 36 #include <iostream>
 37 #include <sstream>
 38 
 39 using namespace NXOpen;
 40 using std::string;
 41 using std::exception;
 42 using std::stringstream;
 43 using std::endl;
 44 using std::cout;
 45 using std::cerr;
 46 
 47 NXOpen::ListingWindow *lw = NULL;
 48 NXOpen::NXMessageBox *mb = NULL;
 49 
 50 void do_it();
 51 void print(const NXString &);
 52 void print(const string &);
 53 void print(const char*);
 54 void showClickMessage(int &iRet);
 55 
 56 //------------------------------------------------------------------------------
 57 // Entry point(s) for unmanaged internal NXOpen C/C++ programs
 58 //------------------------------------------------------------------------------
 59 extern "C" DllExport void ufusr( char *parm, int *returnCode, int rlen )
 60 {
 61     try
 62     {
 63         // 获取NXSession并初始化
 64         NXOpen::Session *theSession = NXOpen::Session::GetSession();
 65         NXOpen::UI *theUI = NXOpen::UI::GetUI();
 66         NXOpen::Part *displayPart(theSession->Parts()->Display());
 67         NXOpen::PDM::PdmSession * pdmSession = theSession->PdmSession();
 68         NXOpen::LogFile *lf = theSession->LogFile();    
 69         lw = theSession->ListingWindow();    
 70         mb = theUI->NXMessageBox();        
 71 
 72         // 获取设置数据
 73         bool isSsoEnabled;
 74         NXOpen::NXString ssoServerUrl;
 75         NXOpen::NXString ssoAppID;
 76         NXOpen::NXString connectString;
 77         NXOpen::NXString discriminator;
 78         pdmSession->GetSsoSettings(&isSsoEnabled, &ssoServerUrl, &ssoAppID);
 79         pdmSession->GetTcserverSettings(&connectString, &discriminator);
 80     
 81         // 查询Teamcenter中零组件 000015200AA000000
 82         NXOpen::PDM::PdmSearchManager *pdmSearchManager = theSession->PdmSearchManager();
 83         NXOpen::PDM::PdmSearch *pdmSearch = pdmSearchManage
首页 上一页 1 2 3 下一页 尾页 1/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Teamcenter_NX集成开发:UF_UGMGR.. 下一篇NX二次开发:保存时导出PDF并打开

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目