Visual Basic.net dll

Visual Basic.net dll

Anonymous
Not applicable
872 Views
4 Replies
Message 1 of 5

Visual Basic.net dll

Anonymous
Not applicable

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

0 Likes
873 Views
4 Replies
Replies (4)
Message 2 of 5

Alfred.NESWADBA
Consultant
Consultant

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
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 3 of 5

Anonymous
Not applicable

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

0 Likes
Message 4 of 5

Alfred.NESWADBA
Consultant
Consultant

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
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 5 of 5

Anonymous
Not applicable

Obrigado. por respomder as minhas dúvidas

Thank you. By respomder my doubts

0 Likes