Search code examples
autodesk-designautomation

Different FileOpenModes using design automation for AutoCAD


I seem to have issues sometimes opening a drawing database. In the past, I used: MyDb.ReadDwgFile(DrawingName, IO.FileShare.ReadWrite, True, Nothing), with the IO.Fileshare.ReadWrite being the point of interest. But, I started having issues with it when I moved to Design Automation. I Later, I found a different file open mode enum of FileOpenMode.OpenForReadAndAllShare and started using it.

I understand both enums are from different libraries (system.io vs autodesk.autocad.databaseservices), but why do I have off and on success using one versus the other? Could it be because of the .dwg version, or because AEC libraries are being loaded? I switched to the autodesk enum and was having success for a while, but now I have some files that pass though and others that don't. For right now, my plan is to try one, check for a failure, then try the other. Is anybody else running into this?


Solution

  • I don't think this is specific to Design Automation. I think the same DWG file will behave the same on your machine too. I suspect what's going on is that you have some unreadable objects in the drawing. ReadWrite will engage the "lazy loading" code path: only the objects that you open are loaded from disk. "...AllShare" will load every object from disk since you want others to be able to access the drawing simultaneously.