How to get fileName of documents returned by aaApi_DocumentSelectDlg (multiple selection) ?

Hi,

When selecting multiple documents with aaApi_DocumentSelectDlg, I can only retrieve the first document file name. 

Here is the code I am using :

vector<PWDocInfo> ret;

AAOPENDOCSDLG2_PARAM param = {};
param.ulMask |= AAOPENDLG2_MASK_FLAGS | AAOPENDLG2_MASK_COUNT | AAOPENDLG2_MASK_TITLE | AAOPENDLG2_MASK_FILEEXTFILTER | AAOPENDLG2_MASK_DOCUMENTID | AAOPENDLG2_MASK_PROJECTID| AAOPENDLG2_MASK_FILENAME ;

param.lpctstrTitle = dlgTitle.data();
param.lpctstrFilter = filter.data();
param.ulFlags = AAOPENDLG2_HIDEREADONLY | AAOPENDLG2_NO_USE_LASTPROJ | AAOPENDLG2_NO_CHANGE_LASTPROJ;


LONG_PTR retCode = aaApi_DocumentSelectDlg(&param);
if ( IDOK != retCode) return;

for( int i = 0; i < param.lCount; i++)
{
    PWDocInfo doc;
    doc.docId = param.plDocumentIds[i];
    doc.filePath = param.pptstrFileName[i]; //Works only with the first document selected !!!
    doc.projectId = param.plProjectIds[i];
    ret.push_back(doc);
}

aaApi_Free(param.pptstrFileName);
aaApi_Free(param.plDocumentIds);
aaApi_Free(param.plProjectIds);

}

Do you see what I am doing wrong ?

Is there a better way to achieve this ? I would like to be able to define the fetch method (checkout, export or copy out) so one of the 3 variants of DocumentExtendedSelectDlg with AAOPENDLG2_MASK_OPENOPTIONS mask could be a better candidate...or even aaApi_ExportDocumentDlg, or aaApi_FetchDocuments !

Thanks in advance for your help

Parents
  • According to the SDK documentation it does not appear it will do what you need for multiple selections.

    [out] Use this argument to access array of the selected document file names.

    The feature is not implemented for multiple selection. Thus the array always holds only one element. Use pptstrFileName[0] to access the path. Pass pptstrFileName to aaApi_Free() to free the memory used by this array.

    To overcome that limitation, you could add this to your loop:

    aaApi_SelectDocument(plProjectIds[i],plDocumentIds[i]);

    doc.FilePath = aaApi_GetDocumentStringProperty(DOC_PROP_FILENAME, 0);

    Answer Verified By: Guillaume Charbonnier 

  • Thank you very much Jeff ! I read several times the documentation but always missed the "feature not implemented for multiple sel" part. The workaround you are proposing seems the way to go.

    Do you know a mean to select the fetch method for aaApi_SelectDocument or aaApi_DocumentExtendedSelectDlg ?

  • The method aaApi_SelectDocument only returns a static data buffer used to get data about the document record. To download the document file, you can use any variety of the fetch commands that correlate to standard ProjectWise commands like Copy Out, Check Out, Give out, Export, etc. I don't have the help file handy right now to give you the exact methods but they shouldn't be too difficult to find. Just be aware that those methods will be subject to any user settings that may limit their functionality. For example, if the document security settings are such that the user does not have file read rights, any attempt to fetch it would fail.

    aaApi_DocumentExtendedSelectDlg may also be a better option when compared to aaApi_DocumentSelectDlg for your needs, but check the documentation to be sure.

  • Sorry I meant aaApi_DocumentSelectDlg i.o aaApi_SelectDocument ...

    So my question is actually how to select the fetch method (copyout, checkout...) using aaApi_DocumentSelectDlg or aaApi_DocumentExtendedSelectDlg method ?

    For what it worth, I have been able to get almost what I want using a combination of aaApi_SelectDocument and aaApi_FetchDocuments but in that case I don't know how to use an extension filter (ex: *.dwg) 

Reply Children
No Data