这个是UF_UI_ask_global_sel_object_list这个UFUN函数的NXOpen版本
NX9+VS2012
#include <uf_defs.h>
#include <NXOpen/NXException.hxx>
#include <NXOpen/Session.hxx>
#include <NXOpen/Part.hxx>
#include <NXOpen/PartCollection.hxx>
#include <NXOpen/UI.hxx>
#include <NXOpen/ListingWindow.hxx>
#include <NXOpen/NXMessageBox.hxx>
#include <NXOpen/NXObject.hxx>
using namespace NXOpen;
Session *theSession = Session::GetSession();
Part *workPart(theSession->Parts()->Work());
Part *displayPart(theSession->Parts()->Display());
UI *theUI = UI::GetUI();
//返回当前选择的对象的数量
int index = theUI->SelectionManager()->GetNumSelectedObjects();
theSession->ListingWindow()->Open();
for (int i = 0; i < index; i++)
{
//返回选择列表上的第n个对象
NXObject *object = theUI->SelectionManager()->GetSelectedObject(i);
//打印tag
char msg[256];
sprintf(msg, "tag:%d",object->Tag());
theSession->ListingWindow()->WriteLine(msg);
}
阿飞
2021年9月4日
阿飞
2021年9月4日