How to batch fix errors in side database?

How to batch fix errors in side database?

swaywood
Collaborator Collaborator
385 Views
2 Replies
Message 1 of 3

How to batch fix errors in side database?

swaywood
Collaborator
Collaborator

How to batch fix errors in side database?

I use command audit,but failed.

 

    [CommandMethod("Q11")]
    public void Q11()
    {
      Database db = HostApplicationServices.WorkingDatabase;
      Document doc = AcadApp.DocumentManager.MdiActiveDocument;
      string sFolder = @"c:\test";
      DirectoryInfo folder = new DirectoryInfo(sFolder);
      FileInfo[] chldFiles = folder.GetFiles("*.dwg");
      using (Transaction trans = db.TransactionManager.StartTransaction())
      {
        foreach (FileInfo fi in chldFiles)
        {
          string sDwg = fi.FullName;
          try
          {
            using (Database dbInsert = new Database(false, false))
            {
              dbInsert.ReadDwgFile(sDwg, System.IO.FileShare.ReadWrite, true, null);
              AcadApp.DocumentManager.GetDocument(dbInsert).Editor.Command("audit", "y");
              dbInsert.SaveAs(sDwg, DwgVersion.AC1027);
            }
          }
          catch
          {
          }
        }
        trans.Commit();
      }
    }

 

0 Likes
Accepted solutions (1)
386 Views
2 Replies
Replies (2)
Message 2 of 3

_gile
Consultant
Consultant
Accepted solution

Hi,

You cannot call Editor.Command in a side database as you do not have acces to the Editor.

You can try the DatabaseExtension.Audit method.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 3

swaywood
Collaborator
Collaborator

GILE, THANKS AGAIN!

0 Likes