.NET

Reply
Active Member
marcelogarcia3251
Posts: 8
Registered: ‎05-19-2013
Message 1 of 5 (254 Views)

Visual Basic.net dll

254 Views, 4 Replies
11-23-2013 09:05 AM

Good afternoon everyone, I am working with microsoft visual basic 2010 and create aPlugIM Tries to AutoCAD 2013 I can not recreate the ThisDrawing variable, put the reference as attached image, the problem occurs on the line that is red in color soon afterMdiActiveDocument not appear to AcadDocument option to terminate the line I believe it should be missing some dll if anyone else has experienced this and can help me.

 

Public Class AdskCommads
Public ReadOnly Property ThisDrawing() As AcadDocuments
Get
Return Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
End Get
End PropertyDoc1.pdf
End Class

*Expert Elite*
Alfred.NESWADBA
Posts: 8,982
Registered: ‎06-29-2007
Message 2 of 5 (242 Views)

Re: Visual Basic.net dll

11-23-2013 10:53 AM in reply to: marcelogarcia3251

Hi,

 

Public ReadOnly Property ThisDrawing() As AcadDocuments
Get
Return Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
End Get

 

You can only return an object that matches the type of the property, and MdiActiveDocument is completly different to the AcadDocuments type.

So assuming you want to have the COM/ActiveX type that describes your drawing-document (singular! not AcadDocuments) you should change the code to:

 

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

 

HTH, - alfred -

PS: set your property "copy-local" for your reference to AcCoreMgd.dll to false, in your screenshot it looks like it's set to true.

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Active Member
marcelogarcia3251
Posts: 8
Registered: ‎05-19-2013
Message 3 of 5 (226 Views)

Re: Visual Basic.net dll

11-23-2013 01:03 PM in reply to: marcelogarcia3251

Hi,

      thanks for replying worked perfectly for creating the variable ThisDrawing.
          When I run in AutoCAD, it shows me the following message that is in the picture, do not know how to proceed, if you can give me any other tips as I am new to. NET. (See the program code attached)
           Sorry for any errors in English because I live in Brazil.

Mensagem.jpg

*Expert Elite*
Alfred.NESWADBA
Posts: 8,982
Registered: ‎06-29-2007
Message 4 of 5 (221 Views)

Re: Visual Basic.net dll

11-23-2013 01:09 PM in reply to: marcelogarcia3251

Hi,

 

you try to cast an object from type Document (managed) to an AcadDocument (COM/ActiveX object), that does not work that way.

So the next step is to tell the debugger to stop at exceptions ... you can see then in debug-mode what line of code raises that exception.

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Active Member
marcelogarcia3251
Posts: 8
Registered: ‎05-19-2013
Message 5 of 5 (158 Views)

Re: Visual Basic.net dll

11-26-2013 03:35 PM in reply to: marcelogarcia3251

Obrigado. por respomder as minhas dúvidas

Thank you. By respomder my doubts

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.