该内容已在博客园发布。Teamcenter_NX集成开发:通过NXOpen查询零组件是否存在 - huangym1 - 博客园 (cnblogs.com)
之前用过NXOpen PDM的命名空间下的类,现在记录一下通过PDM命名空间下的类查询Teamcenter零组件的信息,也可以用来判断该零组件是否存在。
1-该工程为DLL工程,直接在NX界面调用,所以直接获取NXSession。
2-查询函数advanced用到的查询为:__NX_STD_ANY_ITEM_QUERY,可以在Teamcenter查询构建器模块中看到该查询。
![](https://i-blog.csdnimg.cn/blog_migrate/c2d908a454466fd751d8312c5bd87b62.png)
// Mandatory UF Includes
#include <uf.h>
#include <uf_object_types.h>
// Internal Includes
#include <NXOpen/ListingWindow.hxx>
#include <NXOpen/NXMessageBox.hxx>
#include <NXOpen/UI.hxx>
#include <NXOpen/LogFile.hxx>
// Internal+External Includes
#include <NXOpen/Annotations.hxx>
#include <NXOpen/Assemblies_Component.hxx>
#include <NXOpen/Assemblies_ComponentAssembly.hxx>
#include <NXOpen/Body.hxx>
#include <NXOpen/BodyCollection.hxx>
#include <NXOpen/Face.hxx>
#include <NXOpen/Line.hxx>
#include <NXOpen/NXException.hxx>
#include <NXOpen/NXObject.hxx>
#include <NXOpen/Part.hxx>
#include <NXOpen/PartCollection.hxx>
#include <NXOpen/Session.hxx>
#include <NXOpen/PDM_SoaConnectionHandle.hxx>
#include <NXOpen/PDM_PdmSession.hxx>
#include <NXOpen/PDM_PdmSearch.hxx>
#include <NXOpen/PDM_PdmFile.hxx>
#include <NXOpen/PDM_PdmNavigatorNode.hxx>
#include <NXOpen/PDM_PdmPart.hxx>
#include <NXOpen/PDM_PdmSearchManager.hxx>
#include <NXOpen/PDM_SoaQuery.