VB.NET Reference to "thisdrawing"

VB.NET Reference to "thisdrawing"

Anonymous
Not applicable
4,573 Views
12 Replies
Message 1 of 13

VB.NET Reference to "thisdrawing"

Anonymous
Not applicable
I am trying to convert a VBA program into a VB.NET program. I am wondering how do I get a reference to "thisdrawing", or the currently active drawing using VB.NET?

Thanks
0 Likes
4,574 Views
12 Replies
Replies (12)
Message 2 of 13

Anonymous
Not applicable
ok i think im on the right track but i cant get intelli-sence to recognize Autodesk.ApplicationServices im not sure what reference library im missing...
0 Likes
Message 3 of 13

Anonymous
Not applicable
ok i fixed that problem...

I am trying to get a reference to the currently active drawing, but im getting an error on the first step. FileNotFoundException was unhandled. The specified module could not be found. (Exception from HRESULT: 0x8007007E)

The inner exception is null and the file name is null... I get the error with the following code:

Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim AcadApp As AcadApplication
AcadApp = CType(ApplicationServices.Application.AcadApplication, AcadApplication)
End Sub

End Class

If I comment out AcadApp = CType(ApplicationServices.Application.AcadApplication, AcadApplication) i no longer get the error, but if i put it in a try catch, it wont catch it... what am i doing wrong?
0 Likes
Message 4 of 13

Anonymous
Not applicable
I was just going to post a message for the exact same thing.

Please post the answer if you find it.

Cheers.
0 Likes
Message 5 of 13

Anonymous
Not applicable
I just found the answer to my problem (and its bad).

I don't know if it applies to you.


You can't use the managed wrappers for ObjectARX
in a standalone application, or from any other process.

They can only be used by a DLL that's loaded into
AutoCAD using NETLOAD.


hth
0 Likes
Message 6 of 13

Anonymous
Not applicable
This is generaly true, but it's not absolute.
Open the following link for a workaround.
http://snippetsandmusings.blogspot.com/2005/12/net-remoting-and-autocad-managed.html
0 Likes
Message 7 of 13

Anonymous
Not applicable
Thanks I found that last night and put it in my favorites.

I need to create a custom palette so I don't know if it will help in my case. I haven't really read it closely yet.

Thanks for the info all the same. 🙂
0 Likes
Message 8 of 13

Anonymous
Not applicable
Wow. That helps emencely. Thank you.
0 Likes
Message 9 of 13

rmichels
Participant
Participant
Hey guys, I and trying this same thing and I am getting no where? Can you help me out?

Thanks
Big R
0 Likes
Message 10 of 13

Anonymous
Not applicable
_

Public Sub ThisDrawing()

Try

MsgBox("ThisDrawing = " &
Application.DocumentManager.MdiActiveDocument.Name)

Catch ex As System.Exception

MsgBox(ex.Message)

End Try

End Sub

Joe ...

wrote in message news:5997576@discussion.autodesk.com...
Hey guys, I and trying this same thing and I am getting no where? Can you
help me out?

Thanks
Big R
0 Likes
Message 11 of 13

Anonymous
Not applicable
I'm afraid it's not nearly as simple as Joe seems to think. There's no functional equivalent to VBA's 'ThisDrawing' in .NET.

In VBA, 'ThisDrawing' is a reference to the active document, and its events.

When you handle an event of 'ThisDrawing' in VBA, the event fires for every document, not only the one you manually reference via MdiActiveDocument. In .NET, if you add a handler to an event of Document object returned by MdiActiveDocument, the event fires only for that document, it does not fire fir every document.

In VB.NET, you have to handle the events of the DocumentCollection class (e.g., DocumentAdded and DocumentToBeDestroyed), and in the handlers of those events, you must add/remove Document event handlers for each document.

I'm afraid that's not a trival task especially for an entry level programmer, however.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

wrote in message news:5997576@discussion.autodesk.com...
Hey guys, I and trying this same thing and I am getting no where? Can you help me out?

Thanks
Big R
0 Likes
Message 12 of 13

Anonymous
Not applicable
I cant access that link. it says i dont have access and its invite only?
How can i read it?
0 Likes
Message 13 of 13

Anonymous
Not applicable

Hi Pavlos,

 

I can´t read the blog, I need an authorization,can you help me?

0 Likes