Recover API – New API in AutoCAD 2015

By Virupaksha Aithal

A long time request by developer community is to recover the drawing files through API. That request has been addressed in AutoCAD 2015. Now, document collection class has a new API “AppContextRecoverDocument” which takes the name of the drawing file to recover. This API is present in ObjectARX and in .NET. In ObjectARX use AcApDocManager::appContextRecoverDocument() API.

[CommandMethod("RecoverTest", CommandFlags.Session)] publicvoid RecoverTest() // This method can have any name {     Document doc =          Application.DocumentManager.MdiActiveDocument;     DocumentCollection docs = Application.DocumentManager;     Editor ed = doc.Editor;      OpenFileDialog file =          newOpenFileDialog("Select file to recover", null,                             "dwg;dxf", "Recover",            OpenFileDialog.OpenFileDialogFlags.DoNotTransferRemoteFiles);                   //show the dialog and take the dwg input     System.Windows.Forms.DialogResult dr =  file.ShowDialog();     if (dr != System.Windows.Forms.DialogResult.OK)            return;     try     {         //call  AppContextRecoverDocument to revover the selected DWG.         docs.AppContextRecoverDocument(file.Filename);     }     catch     {         ed.WriteMessage("Unable to recover the drawingn");     } }

Comments

8 responses to “Recover API – New API in AutoCAD 2015”

  1. Z Graff Avatar
    Z Graff

    This is a nice addition, however it doesn’t appear to work! AppContextRecoverDocument wont seem to take any of the paths I can come up with. A path that will work with docs.Open wont work with docs.AppContextRecoverDocument
    Any ideas?

  2. Z Graff Avatar
    Z Graff

    In fact I omitted the CommandFlags.Session, which appears to be a necessary component.
    Problem solved.

  3. but this doesn’t exist in RealDwg because there is no implementation of ApplicationServices but the docs don’t mention that (they do mention this functionality, just as a tease) so if you paid for RealDwg just forget you ever saw this ok?

  4. I am using your above code as it is, to recover a corrupt file, but it giving ‘eNotApplicable’ error. Could you please help me.

  5. James Cameron Avatar
    James Cameron

    The command only works in SDI 1

  6. Well… interesting, having just moved to AutoCAD 2017, this explains why ‘our’ third party’s objects get reduced to Proxy objects when RECOVER is used. Although, we were previously on 2016… I think RECOVER worked then. Why does it not work now?

  7. Hi
    Could this APIruns on CAD2014?

  8. Hi
    I have no idea about this language I am coding using lisp, So
    Could this API runs on CAD2014? and How?

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading