I'm migrating a project which totally worked just freaking fine from 2012 to 2014.
I get this error:
'CloseAndSave' is not a member of 'Autodesk.AutoCAD.ApplicationServices.Document'
but yet AUTODESK's help site says this:
"The CloseAndDiscard or CloseAndSave
methods of the Document object are used to close an open
drawing and discard or save any changes made."
so what DOCUMENT object are they refering to?
here is some of my relevent code:
Dim newDoc As Document '...... '.... '.. hundreds of lines of code go here.... If Valid = True Then Try ' newDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open(myFIO.FullName, False) Dim acDocMgr As DocumentCollection = Application.DocumentManager newDoc = DocumentCollectionExtension.Open(acDocMgr, myFIO.FullName, False) Catch ex As Exception OPenError = myFIO.FullName & " " & ex.Message & vbCr & vbCr End Try Try Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument = newDoc Catch ex As Exception OPenError = myFIO.FullName & " " & ex.Message & vbCr & vbCr Goofed = True End Try If Goofed = False Then ChangeXrefPath(Path, ACF.Db) Try newDoc.CloseAndSave(myFIO.FullName) Catch ex As Exception SaveError = myFIO.FullName & " " & ex.Message & vbCr & vbCr newDoc.CloseAndDiscard() End Try newDoc = Nothing myFIO = Nothing Else End If Else End If
FYI, on a semi-related note,I replaced the commented out line (from the 2012 version)with the 2 that follow it per the example on the ADSK help site, since the OPEN method was no longer a method of the document manager.
Hi,
Just a little precision about extension methods using with VB.
With AutoCAD 2013 some methods have been moved to another class (see the Migration Guide topic in the ObjectARX 2013 \Docs\arxmgd.chm file).
For exmple the DocumentCollection.Add() method became an extension method defined in the DocumentCollectionExtension class (or module in VB).
Extension methods can be called both way (assuming docCol = Application.DocumentManager):
- as static (Shared) methods:
doc = Autodesk.AutoCAD.ApplicationServices.DocumentCollectionExension.Add(docCol, "acad.dwt")
- as instance methods of the extended type:
doc = docCol.Add("acad.dwt")
The second one will directly work with C# because DocumentCollectionExtension is a class of the ApplicationServices namespace.
But with VB extension methods have to be defined in a Module, so, the DocumentcollectionExtension module have to be imported first for this behavior to be available.
Imports Autodesk.AutoCAD.ApplicationServices.DocumentCollectionExtension