其他分享
首页 > 其他分享> > NX二次开发 图纸模块相关函数

NX二次开发 图纸模块相关函数

作者:互联网

环境: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;
}

 

标签:std,图纸,string,res,NX,tmpName,endKeyword,二次开发,size
来源: https://blog.csdn.net/qq_30722721/article/details/113847995