Solved! Go to Solution.
Solved by drambo61. Go to Solution.
Why not just use the window filesystem FILE.COPY to make the new file (copy your prototype file to the desired location and rename)? Then open the new document and do your work.
Hi Michael,
Thanks for the response. I suppose that is one alternative. It just grinds me when I've got two simple lines of VBA code that I have to completely revamp to put into .NET.
Also, after letting ACAD send the error data back to AutoDesk, it informed me that a patch was available to help with this issue. After downloading it and applying, it seems to have fixed the problem. So now I have to go back thru the 5 different ways I've tried to solve this to find the "best" one.
Thanks again,
Dave
I'm somewhat new to this myself, but I just finished converting one of my VBA programs. The issue may be with the command flag settings. Try this:
<CommandMethod("DrawingInUI")> _
Public Sub DrawingInUI()
Dim MYDocMgr As DocumentCollection = Application.DocumentManager
Dim MYDoc As Document
Dim testDB As New Database(False, True)
Dim fileName As String = "Test" 'new drawing name
Dim MyPath = "c:\" & fileName & ".dwg" 'Path to save new drawing to.
testDB.ReadDwgFile("N:\ACAD\DWG\ENG-DWG\TITLE\AFE-TITLE-2.dwg", FileOpenMode.OpenForReadAndAllShare, True, "")
'Path of template file to open as a new drawing - in this case a drawing with a title block.
Try
testDB.SaveAs(MyPath, DwgVersion.Current) 'Save the template drawing as a new drawing (without opening it up in the user interface)
testDB.Dispose()
Catch
End Try
MYDoc = MYDocMgr.Open(MyPath, False, "") ' Open the newly created drawing up into the user interface.
DocumentManager.MdiActiveDocument = MYDoc
End Sub