I have simple custom exporter based on IExportContext.
When during exporting I use scroll wheel then exporting is canceled in the middle of proccess (in random place).
IsCanceled() method always return false.
No exception is throw.
Question:
How to avoid canceling export when user use scroll wheel?
Solved! Go to Solution.
Solved by jeremytammik. Go to Solution.
Dear Artur,
Sorry for the late response.
Hmm. I have no news so far. I wonder how this can be communicated to the development team. I don't know how to reproduce this. Do I need any special equipment? I don't have a scroll wheel to test with. I have never heard anyone else reporting anything similar. Can you provide a reproducible case?
http://thebuildingcoder.typepad.com/blog/about-the-author.html#1b
Thank you!
Cheers,
Jeremy
Hi Jeremy,
Thank you for answer.
Steps to reproduce:
1. Take any custom exporter
(for example: http://thebuildingcoder.typepad.com/blog/2013/07/graphics-pipeline-custom-exporter.html#5)
2. Load any Revit project
3. Go to {3D} view
4. Start export
5. During export use mouse wheel
Dear Artur,
Thank you for your update and renewed prompting.
Yes, I have reproduced the issue.
To do so, I migrated the sample you pointed out to Revit 2017 and posted it on GitHub:
https://github.com/jeremytammik/CustomExporterCollada
When I run the command and activate the mouse scroll wheel, an exception of type ExternalApplicationException is thrown from within the call to `exporter.Export(view3D)`, saying
Object reference not set to an instance of an object.
I remember seeing the same exception being thrown once before.
It was reported in several comments by Helen Huang on
http://thebuildingcoder.typepad.com/blog/2013/07/adn-mesh-data-custom-exporter-to-json.html
I reported it to the development team in the database issue REVIT-94525 [API CustomExporter throws ExternalApplicationException after call to Finish].
This issue has been verified by the development team and classified as Code Fix Needed, submitting a new issue REVIT-100187 [API CustomExporter throws ExternalApplicationException after call to Finish].
That issue is still open.
I added a note of your report to it.
The case faced by Helen was easy to work around: simply add an exception handler around the call to `Finish`:
try { exporter.Export( view ); } catch( Autodesk.Revit.Exceptions.ExternalApplicationException ex ) { Debug.Print( "ExternalApplicationException " + ex.Message ); }
Here is the code for that case on GitHub:
https://github.com/jeremytammik/CustomExporterAdnMeshJson
Here is the fix I applied:
I created a new GitHub repository for the sample you pointed to:
https://github.com/jeremytammik/CustomExporterCollada
It contains the code you point to in a solution for Revit 2017.
I added the same workaround to your code as well:
That seems to resolve the problem.
The fixed version is marked as release 2017.0.0.1:
https://github.com/jeremytammik/CustomExporterCollada/releases/tag/2017.0.0.1
I hope this helps.
Best regards,
Jeremy
Thank you Jeremy,
The another workaround I found is to disable of scroll wheel for the time of export.
How do you disable the use of the scroll wheel for the time of export, please?
Thank you!
Cheers,
Jeremy
I used EnableWindow() function on view window.
The name of view window ("AfxFrameOrView140u") I found via Spy++.
Here is class I made. Tested on Revit 2017 so far.
class RevitWindowUtility { [DllImport("user32.dll", SetLastError = true)] public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow); [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] static extern bool EnableWindow(IntPtr hWnd, bool bEnable); static IntPtr viewWindowHwnd = IntPtr.Zero; public static IntPtr FindChildWindow(IntPtr hwndParent, string lpszClass, string lpszTitle) { return FindChildWindow(hwndParent, IntPtr.Zero, lpszClass, lpszTitle); } public static IntPtr FindChildWindow(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszTitle) { IntPtr hwnd = FindWindowEx(hwndParent, IntPtr.Zero, lpszClass, lpszTitle); if (hwnd == IntPtr.Zero) { IntPtr hwndChild = FindWindowEx(hwndParent, IntPtr.Zero, null, null); while (hwndChild != IntPtr.Zero && hwnd == IntPtr.Zero) { hwnd = FindChildWindow(hwndChild, IntPtr.Zero, lpszClass, lpszTitle); if (hwnd == IntPtr.Zero) { hwndChild = FindWindowEx(hwndParent, hwndChild, null, null); } } } return hwnd; } public static IntPtr GetRevitMainWindowHwnd() { Process process = Process.GetCurrentProcess(); return process.MainWindowHandle; } public static void FindViewWindowHwnd() { IntPtr mainWindowHwnd = GetRevitMainWindowHwnd(); viewWindowHwnd = FindChildWindow(mainWindowHwnd, IntPtr.Zero, "AfxFrameOrView140u", null); } public static void EnableViewWindow(bool enable) { if (viewWindowHwnd == IntPtr.Zero) { FindViewWindowHwnd(); } if (viewWindowHwnd != IntPtr.Zero) EnableWindow(viewWindowHwnd, enable); }
Dear Artur,
Thank you for your super cool sample code snippet.
I hope others can find lots of interesting uses for this direct access to the view window.
Long live Spy++!
Cheers,
Jeremy