.NET

Reply
Active Contributor
43 Posts
0 Kudos
Registered: ‎06-30-2006
Post 1 of 11
Accepted Solution

Load dll-files in Acad2013

2907 Views, 10 Replies
03-29-2012 12:42 AM

Someone already tried to load VB dll's in Acad2013? 

They dont work for me - no message and no error, nothing happens.

 

in 2012 they worked well.

Hi,

 

one global change you have to do is to add a new DLL to the references:

AcCoreMgd.dll

 

To your statement getting asscess to the COM-based AcadDocument you have to use this way:

 

Dim tAcadDoc as ApplicationServices.Document
Dim tAcadDocCOM as Interop.AcadDocument
tAcadDoc = ApplicationServices.Application.DocumentManager.MdiActiveDocument
tAcadDocCOM = CType(ApplicationServices.DocumentExtension.GetAcadDocument(tAcadDoc), Interop.AcadDocument)

 

HTH, - alfred -

*Expert Elite*
9,836 Posts
1,219 Kudos
Registered: ‎06-29-2007
Post 2 of 11

Re: Load dll-files in Acad2013

03-29-2012 12:44 AM in reply to: s.hofer

Hi,

 

do you mean VB6 dll's oder VB.NET dll's

Have you set new references (according to AutoCAD 2013/19.0) before you compiled the DLL's?

 

A little bit little, your info :smileywink:

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Active Contributor
43 Posts
0 Kudos
Registered: ‎06-30-2006
Post 3 of 11

Re: Load dll-files in Acad2013

03-29-2012 01:33 AM in reply to: Alfred.NESWADBA

ahhhh

you'r right i have to rebuild my scripts with the r19 references...

i hope this works - i get errors in my code with the new references.

 

thanks

*Expert Elite*
9,836 Posts
1,219 Kudos
Registered: ‎06-29-2007
Post 4 of 11

Re: Load dll-files in Acad2013

03-29-2012 01:37 AM in reply to: s.hofer

Hi,

 

>> i get errors in my code with the new references

Yes, there are some modifications necessary to your code as there are some moves of functions/properties to different DLLs/different namespaces. But as long as we don't see what error you have we can't do anything for you :smileywink:

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Active Contributor
43 Posts
0 Kudos
Registered: ‎06-30-2006
Post 5 of 11

Re: Load dll-files in Acad2013

03-29-2012 02:34 AM in reply to: Alfred.NESWADBA

ok, one error left...

    Public ReadOnly Property ThisDrawing As AcadDocument
        Get
            Return   Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.AcadDocument
        End Get
    End Property

 msg:

AcadDocument is not a member of Autodesk.AutoCAD.ApplicationServices.Document

*Expert Elite*
9,836 Posts
1,219 Kudos
Registered: ‎06-29-2007
Post 6 of 11

Re: Load dll-files in Acad2013

03-29-2012 07:13 PM in reply to: s.hofer

Hi,

 

one global change you have to do is to add a new DLL to the references:

AcCoreMgd.dll

 

To your statement getting asscess to the COM-based AcadDocument you have to use this way:

 

Dim tAcadDoc as ApplicationServices.Document
Dim tAcadDocCOM as Interop.AcadDocument

tAcadDoc = ApplicationServices.Application.DocumentManager.MdiActiveDocument

tAcadDocCOM = CType(ApplicationServices.DocumentExtension.GetAcadDocument(tAcadDoc), Interop.AcadDocument)

 

HTH, - alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Active Contributor
43 Posts
0 Kudos
Registered: ‎06-30-2006
Post 7 of 11

Re: Load dll-files in Acad2013

03-29-2012 11:23 PM in reply to: Alfred.NESWADBA

Ty for your help, but i have a other problem now LOL :smileysad:

 

EDIT:

OK, i updated my project to NETframework 4.0... seems to work now. Thank you very much!

Active Contributor
43 Posts
0 Kudos
Registered: ‎06-30-2006
Post 8 of 11

Re: Load dll-files in Acad2013

03-30-2012 12:04 AM in reply to: s.hofer

To get "ThisDrawing" i use

Return DocumentExtension.GetAcadDocument(Application.DocumentManager.MdiActiveDocument)

 now.

 

if someone have the same problem...

Active Member
10 Posts
0 Kudos
Registered: ‎01-07-2015
Post 9 of 11

Re: Load dll-files in Acad2013

01-07-2015 02:33 AM in reply to: Alfred.NESWADBA

Thanks Alfred,

 

DocumentExtension worked for me.

I have to make a code of my ex-colleague usable for AutoCAD 2015, so i don't have much experience with the code.

The problem is that  he declared tAcadDoc as editor.

If i use your code i wont get that error anymore (tAcadDoc --> doc1) (tAcadDocCOM --> ed) but it gives me extra errors after it.

 

Dim ed as ApplicationServices.Document

Dim doc1 as Interop.AcadDocument

 

ed = ApplicationServices.Application.DocumentManager.MdiActiveDocument

 

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

 

 

Old code:

  Dim doc1 As Autodesk.AutoCAD.Interop.AcadDocument = Application.DocumentManager.MdiActiveDocument.AcadDocument

            Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor

 

 

Because ed is now declared as ApplicationServices.Document, i can't use for example ed.WriteMessage because it's not declared as editor anymore:

 

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

 

I have added accoremgd, acdbmgd, AcDx, Acmgd, AutoCAD, Interop, Interop.Common and AXDBLib to the references

 

Can you help me further?

 

Arjan

 

 

 

 

 

 

 

 

Active Contributor
43 Posts
0 Kudos
Registered: ‎06-30-2006
Post 10 of 11

Re: Load dll-files in Acad2013

01-07-2015 04:16 AM in reply to: J.Verhoef2251
Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor

 try this...

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!