Database.Save e eFileInternalErr: bug di AutoCAD

19. dicembre 2007

In AutoCAD 2008 eseguendo il metodo managed ObjectARX:

Application.DocumentManager.MdiActiveDocument.Database.Save()

viene sollevata l'eccezione:

eFileInternalErr

ed il dwg non viene salvato.

Si tratta di un bug (l'ennesimo...) dell'API di AutoCAD.

Per aggirare il problema è sufficiente utilizzare il metodo SaveAs passando come nome del file il nome del dwg corrente:

Application.DocumentManager.MdiActiveDocument.Database.SaveAs

(Application.DocumentManager.MdiActiveDocument.Database.Filename, Autodesk.AutoCAD.DatabaseServices.DwgVersion.Current)

Oppure è possibile invocare il comando "_qsave".

E' veramente incredibile che un prodotto software di questo livello contenga dei bug di questo genere. 

[EDIT]

Grazie a Giuliano per questa segnalazione relativa alla documentazione:

"You can't save a database to the same file it was read from, because it may not have been completely read in initially, so saving to the same file poses the risk of concurrently reading/writing to the same file. The SAVE command uses saveAs() to save to a different (e.g., temporary) file and then either deletes or renames the original to *.bak, and then renames the saved file to the original filename. "

Resta valida la soluzione che propongo per salvare sullo stesso file.

AutoCAD e ObjectARX