[Explorer API] Export Revit File Issue

Hi Experts,

I'm trying to export Revit models from a folder in ProjectWise, I've tried to use these API functions:

aaApi_FetchDocumentFromServer

aaApi_CopyOutDocument

aaApi_ExportDocument

But they all failed, the return value is false, and only a 0k size file downloaded.

Please note I've used these APIs to export Microstaion Dgn files for many years, without any problem.

So what's the problem with Revit model exporting? Does anyone meet the same problem? Thanks a lot.

  • ,

    A little more detail would be helpful.  A code snippet would go a long way to providing some context, along with details such as which documents, their status, error messages (if any), as well as software versions, etc.

    I understand that you are a bit frustrated and want some help, but for some reason, it is common for folks to state a problem in a way that doesn't give a good starting point to troubleshoot any underlying problems.  It would be like stating a problem about your car not starting like this:  "My car won't start.  What's wrong with it?  It always started before."  You would give some context about the conditions along with what you have tried so far.

    And screenshots help a great deal. 

    Here's what I think I know so far:

    The return code indicates failure, so there would be an error code.  What are the errors?

    You say that "only a 0k size file is downloaded".  What do you mean by that?  If the functions fail, and a file is created, but is "empty", the file transfer must be starting, so I would start by checking things related to files, i.e. is there enough room on the device where the file is being created, time outs, security, networking, etc.  Also does this process work OK when using ProjectWise Explorer, or is it only failing in your code?

  • Thanks Dan for you quick reply. The reason I didn't put much details is because the code runs well when exporting Dgn files.

    My goal is to export only the Revit master file. It's an C# console application which wraps some PW APIs.

    [DllImport("dmscli.dll", CharSet = CharSet.Unicode, ExactSpelling = false)]
    public static extern bool aaApi_FetchDocumentFromServer(int ulFlags, int lProjectId, int lDocumentId, string lpctstrWorkdir, string lptstrFileName, int lBufferSize);
    
    [DllImport("dmsgen.dll", EntryPoint = "aaApi_GetLastErrorDetail", CharSet = CharSet.Unicode)]
    public static extern IntPtr unsafe_aaApi_GetLastErrorDetail();
    
    public static string aaApi_GetLastErrorDetail()
    {
        return Marshal.PtrToStringUni(unsafe_aaApi_GetLastErrorDetail());
    }
    
    [DllImport("dmsgen.dll", EntryPoint = "aaApi_GetLastErrorMessage", CharSet = CharSet.Unicode)]
    public static extern IntPtr unsafe_aaApi_GetLastErrorMessage();
    
    public static string aaApi_GetLastErrorMessage()
    {
        return Marshal.PtrToStringUni(unsafe_aaApi_GetLastErrorMessage());
    }
            
    [DllImport("dmsgen.dll", CharSet = CharSet.Unicode)]
    public static extern int aaApi_GetLastErrorId();
            
    bool bRet = PWApiWrapper.aaApi_FetchDocumentFromServer(131072, iPWFolderId, DOCUMENT_ID, strProcessPath, null, 260);   //WS: file name is NULL, means use original name.
    
    if (!bRet)
    {
        ShowPWError();
        break;
    }
    
    private static void ShowPWError()
    {
        Console.WriteLine("[{0}]\n{1}\n{2}",
                PWApiWrapper.aaApi_GetLastErrorId(),
                PWApiWrapper.aaApi_GetLastErrorMessage(),
                PWApiWrapper.aaApi_GetLastErrorDetail());
    }

    Running in Debug mode, please see the lastErrorId, and error message:

    The 0 KB file is exported to the designated local folder:

    Please see attached splash message.

    5611.Window_Splash_log.txt

    Hope I've provided enough details, thanks again Dan.

  • Looking at the log file, I see some errors about "failed in ApplyDeltasStreamToFile".  I'm not familiar with what is going on in this case (revit files).  I'm wondering if this type of file requires some additional flags that isn't obvious.  A wild guess would be to add the AAMDS_STREAM_SUPPORTED 0x00800000L for the ulFlags parameter, but that just a guess. 

    I'll try to get someone in support to see if they can look into this as I don't see anything in your code that looks wrong to me and as you pointed it, it works for dgn files, so it does seem logical that there is something "different" about how revit files are transferred.

  • ,

    What specific versions of software are you using?

    • ProjectWise Explorer
    • ProjectWise SDK
    • ProjectWise Integration Service
    • Visual Studio Edition
    • .NET
    • OS
    • Revit

    And can you replicate the issue if you use unmanaged (native) code?

  • Hi Dan,

    The versions are:

    • ProjectWise Explorer        ===>10.00.03.271
    • ProjectWise SDK  ===>100003140
    • ProjectWise Integration Service ===>10.00.03.299
    • Visual Studio Edition ===>2019
    • .NET ===> .NET Framework 4.7
    • OS  ===>Widows 10 Version 20H2
    • Revit ===>2018.3

    Thanks again Dan.