.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

vb project for AutoCAD 2015

2 REPLIES 2
Reply
Message 1 of 3
J.Verhoef2251
519 Views, 2 Replies

vb project for AutoCAD 2015

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

2 REPLIES 2
Message 2 of 3
norman.yuan
in reply to: J.Verhoef2251

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.MdiActiveDocument

 

doc1 = CType(ApplicationServices.DocumentExtension.GetAcadDocument(ed), Interop.AcadDocument)

 

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

Drive CAD With Code

EESignature

Message 3 of 3
J.Verhoef2251
in reply to: 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

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost