Hang while exporting DXF

Hang while exporting DXF

Anonymous
Not applicable
693 Views
5 Replies
Message 1 of 6

Hang while exporting DXF

Anonymous
Not applicable

I'm getting a hang during an automated export process in my plugin in which I also export a DXF: 

 

 	mscorlib.dll!System.Threading.ManualResetEventSlim.Wait(int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) Line 688	C#
 	mscorlib.dll!System.Threading.Tasks.Task.SpinThenBlockingWait(int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) Line 3320	C#
 	mscorlib.dll!System.Threading.Tasks.Task.InternalWait(int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) Line 3259	C#
 	mscorlib.dll!System.Threading.Tasks.Task<Autodesk.Revit.DB.Collaborate.Interface.IProject>.GetResultCore(bool waitCompletionNotification) Line 559	C#
 	RSCloudClient.dll!Autodesk.Revit.DB.Collaborate.SynchronousManagementClientAccess.GetProjectAndModelName(string region, System.Guid projectId, System.Guid modelId, out string projectName, out string modelName)	Unknown
 	RSCloudClientInterop.dll!<Module>.DLLAccess_RSCloudClientInteropImpl.ManagementClientAccess_getProjectAndModelName(DLLAccess_RSCloudClientInteropImpl* value, AString* region, GUIDvalue* projectId, GUIDvalue* modelId, AString* pProjectName, AString* pModelName)	Unknown
 	[Native to Managed Transition]	
 	[Managed to Native Transition]	
 	RevitDBAPI.dll!Autodesk.Revit.Proxy.DB.DocumentProxy.Export(string folder, string name, System.Collections.Generic.ICollection<Autodesk.Revit.Proxy.DB.ElementIdProxy> views, Autodesk.Revit.Proxy.DB.DXFExportOptionsProxy options)	Unknown
 	RevitAPI.dll!Autodesk.Revit.DB.Document.Export(string folder, string name, System.Collections.Generic.ICollection<Autodesk.Revit.DB.ElementId> views, Autodesk.Revit.DB.DXFExportOptions options)	Unknown
>	AppliedVR.dll!AppliedVR.Minimap.MinimapExporter.ExportFloorPlansToDXF(System.Collections.Generic.Dictionary<int, Autodesk.Revit.DB.ViewPlan> floorPlans, string path) Line 264	C#
 	AppliedVR.dll!AppliedVR.Minimap.MinimapExporter.ExportMinimaps(string path, string viewName) Line 68	C#
 	AppliedVR.dll!AppliedVR.ExportContext.Finish() Line 407	C#
 	InterfaceUtilAPI.dll!<Module>.Autodesk.Revit.Proxy.DB.IExportContextBridge.Finish_(Autodesk.Revit.Proxy.DB.IExportContextBridge* value)	Unknown
 	[Native to Managed Transition]	
 	[Managed to Native Transition]	
 	InterfaceUtilAPI.dll!Autodesk.Revit.Proxy.DB.CustomExporterProxy.Export(Autodesk.Revit.Proxy.DB.ViewProxy view)	Unknown
 	RevitAPI.dll!Autodesk.Revit.DB.CustomExporter.Export(Autodesk.Revit.DB.View view)	Unknown
 	AppliedVR.dll!AppliedVR.Exporter.Execute(Autodesk.Revit.UI.UIApplication app, Autodesk.Revit.DB.View3D view3D, string exportPath) Line 30	C#
 	AppliedVR.dll!AppliedVR.App.OnViewActivated(object sender, Autodesk.Revit.UI.Events.ViewActivatedEventArgs e) Line 125	C#
 	RevitAPIUI.dll!UIApplicationViewActivatedEventHelper.ViewActivatedEventHandler(object sender, Autodesk.Revit.Proxy.UI.Events.ViewActivatedEventArgsProxy args)	Unknown
 	APIUIAPI.dll!<Module>.EventExecutorBase<ViewActivatedEventArgs,Autodesk::Revit::Proxy::UI::Events::ViewActivatedEventArgsProxy>.ExecuteHandlers(object sender, ViewActivatedEventArgs* eventArgs, Autodesk.Revit.Proxy.UI.Events.ViewActivatedEventArgsProxy pManagedArgs, System.Delegate handlers)	Unknown
 	APIUIAPI.dll!<Module>.APIEventObserverBaseProxy<ViewActivatedEventArgs,Autodesk::Revit::Proxy::UI::Events::ViewActivatedEventArgsProxy>.handleEvent(APIEventObserverBaseProxy<ViewActivatedEventArgs,Autodesk::Revit::Proxy::UI::Events::ViewActivatedEventArgsProxy>* value, ViewActivatedEventArgs* eventArgs)	Unknown
 	[Native to Managed Transition]	
 	[Managed to Native Transition]	
 	APIUIAPI.dll!<Module>.SelfRegisteringEventObserver<ViewActivatedEventArgs>.handleBaseEvent(SelfRegisteringEventObserver<ViewActivatedEventArgs>* value, MutableEvent* baseEvent)	Unknown
 	[Native to Managed Transition]	
 	[Managed to Native Transition]	
 	UIFramework.dll!UIFramework.FrameWndManager.MDIFrameWindowProc(System.IntPtr hWnd, int Msg, System.IntPtr wParam, System.IntPtr lParam)	Unknown
 	[Native to Managed Transition]	
 	[Managed to Native Transition]	
 	UIFramework.dll!UIFramework.FrameWndManager.onMDIActivate(System.IntPtr hChildWnd, bool bActivate)	Unknown
 	UIFramework.dll!UIFramework.FrameWndManager.MDIFrameWindowProc(System.IntPtr hWnd, int Msg, System.IntPtr wParam, System.IntPtr lParam)	Unknown
 	[Native to Managed Transition]	
 	[Managed to Native Transition]	
 	UIFrameworkServices.dll!UIFrameworkServices.ManageViewsService.InitialUpdateFrame(System.IntPtr frame, System.IntPtr document, UIFrameworkServices.ViewType viewType, bool bMakeVisiable)	Unknown
 	UIFramework.dll!UIFramework.MFCMDIChildFrameControl.setDocument(object owner, System.IntPtr hWnd, System.IntPtr document, UIFrameworkServices.ViewType viewType)	Unknown
 	UIFramework.dll!UIFramework.MainWindow.openMFCFrameWindow(System.IntPtr hWnd, System.IntPtr document, int viewType)	Unknown
 	UIFrameworkInterop.dll!<Module>.AMainWindowWrapper.openFrameWindow(AMainWindowWrapper* value, CFrameWnd* pFrame, CDocument* pDoc, int viewType)	Unknown
 	[Native to Managed Transition]	
 	[Managed to Native Transition]	
 	APIUIAPI.dll!Autodesk.Revit.Proxy.UI.UIApplicationProxy.OpenAndActivateDocument(string fileName)	Unknown
 	RevitAPIUI.dll!Autodesk.Revit.UI.UIApplication.OpenAndActivateDocument(string fileName)	Unknown
 	AppliedVR.dll!AppliedVR.App.ProcessNextModel() Line 286	C#
 	AppliedVR.dll!AppliedVR.Process.Initialize.AnonymousMethod__1(object s) Line 44	C#
 	[Native to Managed Transition]	
 	[Managed to Native Transition]	
 	mscorlib.dll!System.Delegate.DynamicInvokeImpl(object[] args) Line 123	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbackDo(System.Windows.Forms.Control.ThreadMethodEntry tme)	Unknown
 	System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(object obj)	Unknown
 	mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 980	C#
 	mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 928	C#
 	mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Line 917	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallback(System.Windows.Forms.Control.ThreadMethodEntry tme)	Unknown
 	System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbacks()	Unknown
 	System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m)	Unknown
 	System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(System.IntPtr hWnd, int msg, System.IntPtr wparam, System.IntPtr lparam)	Unknown

 

 

The DXF appears to be created, but the function never returns.  Additionally during my export process I'm getting: 

image.png

 

If, instead, I export manually through my plugin, then I don't get the permission error and the DXF exports and does not hang - returning naturally from the function call.

 

My plugin is built for Revit 2021.  This is all happening with the rac_basic_sample_project.rvt from Revit 2020 - so a conversion to 2021 does occur.  If I export the rac_basic_sample_project.rvt from Revit 2021, I don't get this issue.

 

 

Please advise.

0 Likes
694 Views
5 Replies
Replies (5)
Message 2 of 6

jeremy_tammik
Alumni
Alumni

Sorry to hear about this. It sounds like something the development team ought to take a look at. Can you provide a minimal reproducible case for this that I can pass on to them, please?

 

https://thebuildingcoder.typepad.com/blog/about-the-author.html#1b

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 6

Anonymous
Not applicable
Turns out that if I first call OpenDocumentFile before calling OpenAndActivateDocument then this problem occurs.

var doc = uiapp.Application.OpenDocumentFile(model);
var uidoc = uiapp.OpenAndActivateDocument(model);

If I only call OpenAndActivateDocument then this problem goes away?!

We regression tested to find this bug.  Between OpenDocumentFile and OpenAndActivateDocument, I was relinking (if needed) missing files.  I didn't want to call OpenAndActivateDocument because I was initiating some functionality when the document was activated. But I also didn't want to waste the time to save, then close, then OpenAndActivateDocument given that I normally deal with very large projects.

So, given the issue occurred with something as simple as the rac_basic_sample_project (which didn't have missing links), I was able to comment out everything in between and the problem was still occurring.  But after removing the (now unnecessary) OpenDocumentFile, the problem went away.

So is this all expected?
Should I have been able to call OpenDocumentFile and then OpenAndActivateDocument?
Is there an alternate way to "activate" a non-UI based opened document that I should be using instead?
0 Likes
Message 4 of 6

Anonymous
Not applicable

Hi Jeremy,

 

Thanks for you response.  I investigated further and added a comment that mentions the discovery of the cause of the issue.  Hopefully you can help me further.

 

Thanks,

Jason

0 Likes
Message 5 of 6

jeremy_tammik
Alumni
Alumni

Wow. Well, congratulations on solving it. The development team might still be interested in taking a look at the reproducible case, if you would care to submit one.

 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 6 of 6

Anonymous
Not applicable
Hi Jeremy,

Can you address these two questions...

Should I have been able to call OpenDocumentFile and then OpenAndActivateDocument?
Is there an alternate way to "activate" a non-UI based opened document that I should be using instead?
0 Likes