Author Topic: Save, Close, and re-Open a Drawing  (Read 1533 times)

0 Members and 1 Guest are viewing this topic.

MGorecki

  • Guest
Save, Close, and re-Open a Drawing
« on: July 19, 2012, 07:08:58 PM »
Hello,
I would like to have a sub that gets the drawing name, saves it, closes the drawing, then re-opens it (because of a 2010 bug).
This is what I have, but from what I've read I need to have "commandflags.session" to work outside of the drawing.  How would I use it for this sub?  All I've seen is the commandflags.session included in the CommandMethod.
This code is in a sub, in a Module.  The only CommandMethod I have is the command I use to start the code in the "Class" module.  I tried putting it in that command, but it didn't work.

Code - vb.net: [Select]
  1.    ' This will save the current drawing, close the drawing, then re-open it
  2.     Public Sub SaveCloseOpenDwg()
  3.         Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
  4.         Dim acDocMgr As DocumentCollection = Application.DocumentManager
  5.         Dim strDWGName As String = acDoc.Name
  6.  
  7.         ' Save the active drawing
  8.         acDoc.Database.SaveAs(strDWGName, True, DwgVersion.Current, acDoc.Database.SecurityParameters)
  9.         acDocMgr.CloseAll()
  10.         acDocMgr.Open(strDWGName, False)
  11.     End Sub

Thanks

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Save, Close, and re-Open a Drawing
« Reply #1 on: July 19, 2012, 08:35:50 PM »
Show us your 'full' code for that method ...
include the Namespace, Class and method declarations/definitions ... as well as any attribute declarations.
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.