[PW C++] 请问,如何根据PW文件路径获取文件ID或GUID?

如何利用PW中文件地址:pw:\jy-pwsrv2.cjxjy.com:jypwdb1\Documents\数字化\2020年Microstation开发\无标题,

获取该文件的ID或者GUID;

在SDK中找到以下函数是否可以解决该问题:

1. aaApi_SelectDocumentDataBufferByFilePath ;

2. aaApi_GetGuidsFromFileName;

3. aaApi_GetDocGuidsFromFileName .
如果以上函数可以解决,是否可以提供使用方法?
Parents
  • 可以从帮助文档的文明中看出,上面几个 API的FilePath与在PW中的地址栏显示Path不一样。
     
     
    可以使用路径获得目录ID,再找出目录下的文档,再对比一下,获得文档的各个信息。
    LONG aaApi_GetProjectIdByNamePath (LPCWSTR lpctstrPath) This function retrieves the project identifier by the project name path.

    例如:

    public static AADOC_ITEM GetDocIdByPwPath(string docFullPath)
    {
    AADOC_ITEM ai = new AADOC_ITEM();
    string projectpath = docFullPath.Substring(0, docFullPath.LastIndexOf("\\"));
    string docFileName = docFullPath.Substring(docFullPath.LastIndexOf("\\")+1);
    int projectno =ProjFun.aaApi_GetProjectIdByNamePath(projectpath);

    if(projectno<0)
    return ai;

    int docno = -1;
    int lret = aaApi_SelectDocumentsByProjectId(projectno);
    if (lret > 0)
    {
    for (int i = 0; i < lret; i++)
    {
    string docname = aaApi_GetDocumentStringProperty(20, i);
    if (docname == docFileName)
    {
    docno = aaApi_GetDocumentNumericProperty(1, i);
    break;
    }
    }
    }


    ai.lProjectId = projectno;
    ai.lDocumentId = docno;

    return ai;


    }

    Answer Verified By: 明昊 刘 

Reply
  • 可以从帮助文档的文明中看出,上面几个 API的FilePath与在PW中的地址栏显示Path不一样。
     
     
    可以使用路径获得目录ID,再找出目录下的文档,再对比一下,获得文档的各个信息。
    LONG aaApi_GetProjectIdByNamePath (LPCWSTR lpctstrPath) This function retrieves the project identifier by the project name path.

    例如:

    public static AADOC_ITEM GetDocIdByPwPath(string docFullPath)
    {
    AADOC_ITEM ai = new AADOC_ITEM();
    string projectpath = docFullPath.Substring(0, docFullPath.LastIndexOf("\\"));
    string docFileName = docFullPath.Substring(docFullPath.LastIndexOf("\\")+1);
    int projectno =ProjFun.aaApi_GetProjectIdByNamePath(projectpath);

    if(projectno<0)
    return ai;

    int docno = -1;
    int lret = aaApi_SelectDocumentsByProjectId(projectno);
    if (lret > 0)
    {
    for (int i = 0; i < lret; i++)
    {
    string docname = aaApi_GetDocumentStringProperty(20, i);
    if (docname == docFileName)
    {
    docno = aaApi_GetDocumentNumericProperty(1, i);
    break;
    }
    }
    }


    ai.lProjectId = projectno;
    ai.lDocumentId = docno;

    return ai;


    }

    Answer Verified By: 明昊 刘 

Children
No Data