环境:Win10, VS2017,NX1907
1.获取所有图纸页对象
std::vector<tag_t> GetAllSheet()
{
int drawCount = 0;
tag_t* drawingTag = NULL;
UF_DRAW_ask_drawings(&drawCount, &drawingTag);
if (0 == drawCount)
{
return std::vector<tag_t>();
}
std::vector<tag_t> res;
for (int i = 0; i < drawCount; ++i)
{
res.push_back(drawingTag[i]);
}
return res;
}
2. 使用NX对话框,选择对象控件,选中某一个图纸节点时,获取的不是图纸对象,需要转化
//计算得到005-1@0,返回005-1
bool CalSheetUINodeName(tag_t sheetObj, std::string &sheetName)
{
sheetName = "";
if (NULL_TAG == sheetObj)
{
return false;
}
bool res = false;
std::string endKeyword = "@0"; //界面上选择的图纸会有后缀名字
std::string tmpName = COMN_NX::GetObjName(sheetObj);
if (tmpName.size() > endKeyword.size())
{
std::string endValue = tmpName.substr(tmpName.size() - endKeyword.size());
if (endValue == endKeyword)
{
res = true;
sheetName = tmpName.substr(0, tmpName.size() - endKeyword.size());
}
}
return res;
}