This was working in Map 3D 2013...
Basically, what I want to do is:
I modified the code a little bit to try and make it work with Map 2014, but without success.
Here is my code now:
// Open dxf Document Document doc = AcadUtil.DocumentManager.Open(dxfFileName, false); // Lock Document so nothing interferes using (DocumentLock docLock = doc.LockDocument()) { // Save drawing as DWG file using (Transaction tr = doc.Database.TransactionManager.StartTransaction()) { doc.Database.SaveAs(fileName + ".dwg", DwgVersion.Newest); tr.Commit(); } // Set document active so we can close it if (Application.DocumentManager.MdiActiveDocument != doc) { Application.DocumentManager.MdiActiveDocument = doc; } // Dispose db doc.Database.Dispose(); // Close document doc.CloseAndDiscard(); }
Code throws error on doc.CloseAndDiscard();
FatalExecutionEngineError was detected... (see attached screenshot for error details)
I have tryed multiple different things, and now I don't know what to do to make this work.
I read about system variable FIBERWORLD... It is set to 1.
What am I doing wrong??
Thanks for your help.
Solved! Go to Solution.
Solved by creid. Go to Solution.
Update:
I had misplaced my closing bracket for "using (DocumentLock...)"
Still getting the same error though
// Open dxf Document Document doc = AcadUtil.DocumentManager.Open(dxfFileName, false); // Lock Document so nothing interferes using (DocumentLock docLock = doc.LockDocument()) { // Save drawing as DWG file using (Transaction tr = doc.Database.TransactionManager.StartTransaction()) { doc.Database.SaveAs(fileName + ".dwg", DwgVersion.Newest); tr.Commit(); } } // Set document active so we can close it if (Application.DocumentManager.MdiActiveDocument != doc) { Application.DocumentManager.MdiActiveDocument = doc; } // Dispose db doc.Database.Dispose(); // Close document doc.CloseAndDiscard();
Hello,
I would suggest to comment the line where you dispose de document's database. That may be causing problems.
Regards.
Hello Creid,
Based on your code, I have made a little change and it works for me:
[CommandMethod("test")] public void test() { Autodesk.AutoCAD.ApplicationServices.Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open("my document location"); // Lock Document so nothing interferes using (DocumentLock docLock = doc.LockDocument()) { // Save drawing as DWG file using (Transaction tr = doc.Database.TransactionManager.StartTransaction()) { doc.Database.SaveAs("output.dwg", DwgVersion.Newest); tr.Commit(); } } /* // Set document active so we can close it if (Application.DocumentManager.MdiActiveDocument != doc) { Application.DocumentManager.MdiActiveDocument = doc; } // Dispose db doc.Database.Dispose(); */ // Close document doc.CloseAndDiscard(); }
Could you give a try?
Running my code outside debug environment by simply importing my dll in Map 3D 2014 worked!!!
Something in debug must corrupt the stack somehow...
Running my code further revealed another issue I had. I was declaring the FDO Provider (OSGeo.SQLServerSpatial) version in my config file.
Map 3D 2013 uses 3.7 but Map 3D 2014 uses 3.8.
I even realised you don't have to declare the FDO Provider's version at all and it still works!
Thanks for your help it is much appreciated!