I'm migrating a vb project (made for AutoCAD 2012) to work with AutoCAD 2015.
I added accoremgd, acdbmgd, AcDx, Acmgd, AutoCAD, Interop, Interop.Common and AXDBLib to the references.
I also updated .NET framework 3.5 to .NET framework 4.5.
Unfortunately i still had to rewrite some of the code.
I know i have to declare this different:
Dim doc1 As Autodesk.AutoCAD.Interop.AcadDocument = Application.DocumentManager.MdiActiveDocument.AcadDocument
Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
Like this:
Dim ed as ApplicationServices.Document
Dim doc1 as Interop.AcadDocument
ed = ApplicationServices.Application.DocumentManager.MdiActiveDocument
doc1 = CType(ApplicationServices.DocumentExtension.GetAcadDocument(ed), Interop.AcadDocument)
Because ed is now declared as ApplicationServices.Document, i can't use for example ed.WriteMessage:
ed.WriteMessage(vbCrLf & "Initializing - Loading User Preferences - ST-CadCommands." & vbCrLf)
I tried to declare ed as editor but then it says that it can't convert ApplicationServices.Application.DocumentManager.MdiActiveDocument to EditorIput.Editor
Can someone help me further?
Arjan
Your question is rather confusing: you know you want to use variable "ed" to point to Autodesk.AutoCAD.EditorInput.Editor object, yet, you deliberately declare it as Autodesk.AutoCAD.ApplicationServices.Document (saying you "have to"). Why?
Take your code as example:
Dim ed as ApplicationServices.Document
Dim doc1 as Interop.AcadDocument
ed = ApplicationServices.Application.DocumentManager.Md
doc1 = CType(ApplicationServices.DocumentExtension.GetAca
If you really want to against common sense to use "ed" as Document, then you can still access the Editor object for calling WriteMessage() in this way:
ed.Editor.WriteMessage("bla bla..") ''Because ed is Document, its Editor property points to an Editor object
Or
Dim doc As Editor ''delibrately name the variable agianst common sense to confuse whoever reading the code, but the code should work
doc=ed.Editor
doc.WriteMessage("bla bla...")
Norman Yuan
Hi Norman,
Sorry i dont have much vb experience and I am changing my ex-colleague's code.
My question is already answered in another post and it works! 🙂
Thanks for your answer.
Arjan