Backstory
I have a custom add-in for exporting to dwf sheets from both the main and linked models using a single interface. It works by first exporting sheets from the main model, renaming them to a friendlier format, then opening a blank project and closing the main model, then opening the first linked model, and then finally exporting sheets from the linked model and renaming them. This process continues until sheets from all involved models have been exported and then it opens back up the main model.
Issue
This program has been working from Revit 2014 to Revit 2016 Service Pack 2 but since the release of Revit 2016 R2 it has stopped working. It now fails after it has finished exporting and renaming dwfs from the main model. It throws an unrecoverable error and then Revit just fully crashes. When debugging I find the following exception:
System.ComponentModel.Win32Exception was unhandled Message: An unhandled exception of type 'System.ComponentModel.Win32Exception'
occurred in WindowsBase.dll Additional information: Not enough quota is available to process this command
The dump files show the following error:
Process Name - RevitWorker.exe Process Architecture - x64 Exception Code - 0xC000005 Exception Information - The thread tried to read from or write to a virtual
address for which it does not have the appropriate access OS Version - 6.1.7601 CLR Version - 4.0.30319.34209
I've tried installing Revit 2016 R2 Update 1 and Update 2 but the problem still occurs. I'm assuming that the issue has something to do with the new use of multi-process to speed up printing since Revit 2016 R2. I've tried upping the number of processes by setting "ExportDwfNumberOfWorkers" to 4 since the machines we use are quad core and that sped up the export but it still failed in the same spot.
Note - This only seems to happen when printing sheets from both the linked models and the main model and only if I include a large number of sheets from the main model. However, the whole purpose of the tool is for users to be able to select and export their sheets from one interface without having to export from each model individually.
Questions
(1) Are there any recommendations for changes to code using the Export to DWF part of the API based on changes since Revit 2016 R2?
(2) Is Autodesk going to be releasing more updates (a.k.a. bug fixes) for Revit 2016 R2?
Solved! Go to Solution.
Solved by skeletank. Go to Solution.
Update 4 has come out and I'm still running into the same issue. It happens on 'UIApplication.OpenAndActivateDocument' when I try to open a document. I'm using Aaron Lu's Placeholder Solution to open and close each linked model. Below is the underlying exception from the call to 'OpenAndActivateDocument'.
System.ComponentModel.Win32Exception was unhandled ErrorCode=-2147467259 HResult=-2147467259 Message=Not enough quota is available to process this command NativeErrorCode=1816 Source=WindowsBase StackTrace: at MS.Win32.UnsafeNativeMethods.PostMessage(HandleRef hwnd, WindowMessage msg, IntPtr wparam, IntPtr lparam) at System.Windows.Interop.HwndTarget.UpdateWindowSettings(Boolean enableRenderTarget, Nullable`1 channelSet) at System.Windows.Interop.HwndTarget.UpdateWindowPos(IntPtr lParam) at System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage msg, IntPtr wparam, IntPtr lparam) at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler) at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
I was finally able to get this working by setting the registry key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Windows\USERPostMessageLimit" to 1,000,000 from the default value of 10,000. The error "Not enough quota was available to process this command" is triggered when this PostMessage limit is reached. PostMessage is an underlying Windows API function that places messages into a queue. It can be called from such things as Document.OpenAndActivateDocument. The limit is for how many PostMessage calls can be waiting in the queue at once. Since this is being run up by the underlying Revit API code for DWF Exporting and document opening my only hope was to increase the limit.
However, I do recommend that you try this on a single machine first, as I am doing, because I'm not sure what kind of other side effects it may cause. If you have the time then test reducing the amount and see if it still works on your biggest set of models and then stop once you've found the sweet spot. This may take a while though because each time the registry value is changed you will need to restart your machine.