Migration VBA to VBdotNet 2012 - Autocad 2013

Migration VBA to VBdotNet 2012 - Autocad 2013

Anonymous
Not applicable
1,248 Views
7 Replies
Message 1 of 8

Migration VBA to VBdotNet 2012 - Autocad 2013

Anonymous
Not applicable

Regards,
Maybe someone can help me solve my problem.
I wonder why this code does not work when working with AutoCAD 2013:

VBNET2.png

 

I wonder if the way we work with INTEROP, and INTEROP.COMMON, has changed in AutoCAD 2013, and if so what would be the new way of working with these references.

 

When I run the plugin shows me the following error:

VBNET3.png

0 Likes
1,249 Views
7 Replies
Replies (7)
Message 2 of 8

norman.yuan
Mentor
Mentor

There are some changes in AutoCAD .NET API since ACAD2013. In your case you call Document's extension method GetAcadDocument():

 

Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiDocument.GetAcadDocument()

 

FYI, migrating COM based VBA code into .NET API code and yet still using COM API doing the work is not a good choice. When start doing .NET programming withg AutoCAD, it would be better to forget all the COM stuff and try to learn and understand the .NET API, and only turn to COM when you really cannot find a way to do it with .NET API or you really have no time to learn .NET API (then why not stick with VBA?).

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 8

Anonymous
Not applicable
Replacing the inserted code is this:

Thisdrawing = Autodesk.AutoCAD.ApplicationServices.DocumentExtension.GetAcadDocument(Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument)

But unfortunately I get the same error, maybe I'm using wrong: (
0 Likes
Message 4 of 8

norman.yuan
Mentor
Mentor

Document.GetAcadDocument()

 

No argument to be supplied.

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 5 of 8

Anonymous
Not applicable

Does not work I have the following error:

 

vb5.png

 

Error 1 'MdiDocument' is not a member of 'Autodesk.AutoCAD.ApplicationServices.DocumentCollection'.

0 Likes
Message 6 of 8

norman.yuan
Mentor
Mentor

Since Acad2013, you need add 3 managed references:

 

accordmgd.dll

acdbmgd.dll

acmgd.dll

 

It is likely that you missed setting reference to accoremgd.dll.

 

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 7 of 8

Anonymous
Not applicable

If I have added the three references, not what will be the problem, as you show me and should work but still the same.
Anyway thank you very much po devote their time to help me solve my problem.

0 Likes
Message 8 of 8

Anonymous
Not applicable

Already achieved migrate vba to vb.net your help it was very useful, thank you very much.

0 Likes