Author Topic: eNotOpenForWrite error during db.SaveAs  (Read 2947 times)

0 Members and 1 Guest are viewing this topic.

TJK44

  • Guest
eNotOpenForWrite error during db.SaveAs
« on: March 05, 2012, 02:22:03 PM »
I am trying to SaveAs the current open dwg with a new name, I try to use this code but it errors out saying eNotOpenForWrite and AutoCAD then crashes. This is the code I'm using, not sure what I'm missing.

Code: [Select]
        Using curDb As Database = HostApplicationServices.WorkingDatabase
            curDb.SaveAs(dirname, True, DwgVersion.Current, curDb.SecurityParameters)
        End Using

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: eNotOpenForWrite error during db.SaveAs
« Reply #1 on: March 05, 2012, 02:47:30 PM »
Are you calling that from a pallete or form (ie: in Application context) ... if so you may need to try document locking.

Your code looks fine otherwise.

added:
Are you using a 'Session' Flag ?
« Last Edit: March 05, 2012, 02:52:24 PM by Kerry »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

TJK44

  • Guest
Re: eNotOpenForWrite error during db.SaveAs
« Reply #2 on: March 05, 2012, 03:03:23 PM »
Thanks Kerry, this fixed it. It was being called from a form.

Code: [Select]
        Using curDb As Database = HostApplicationServices.WorkingDatabase
            Using doclock As DocumentLock = document.LockDocument()
                curDb.SaveAs(dirname, True, DwgVersion.Current, curDb.SecurityParameters)
            End Using
        End Using