Getting the Active AcadApplication

Getting the Active AcadApplication

Anonymous
Not applicable
632 Views
4 Replies
Message 1 of 5

Getting the Active AcadApplication

Anonymous
Not applicable
I have created an activex dll containing some public methods in that. I have created an Object ARX in which I have defined the command and menu. From that Arx I am calling the public methods in the Activex dll.


For getting the Acad application in the dll I am using the GetObject of VB. My problem is that the GetObject returns the first instance of the AutoCAd if the multiple instances of the AutoCAd are running. Some times it happens that we have called the command from some where elae and it is running some where else. To get the solutions of this I tried to expose the application property in my dll and setting its balue from my Arx application, but when the wraper class is created it converts IAcadApplication data type in dll as structure. But when we are adding class from tlb, IAcadApplication is a class and hence conflicts is created. There is one solution to develop the whole application in C++ as object arx but that will take a lot of time and this is the reason I am developing the dlls in VB and trying to call it from an arx. So can any body help me out so that I can get the Application object of the Active acad application and not the first running ACAd application?



Thanks in advance



Manoj
0 Likes
633 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
"manoj_vest" wrote in message
news:f1344f6.-1@WebX.maYIadrTaRb...

> My problem is that the GetObject returns the first instance
> of the AutoCAd if the multiple instances of the AutoCAd
> are running.

This is a known limitation of GetObject and there's precious little you
can do about it from the VB side. Even Autodesk's own AsdkUnsupp2000 has
problems with this.

My preferred solution is to create a VLX launcher. The class in question
should have a public, writable Application porperty. You can then use
the VLX file to create an instance of your class and set the Application
property using (vlax-get-acad-object) which always returns the session
in which it is called.

--
There are 10 kinds of people:
Those who understand binary and those who don't
http://www.acadx.com
0 Likes
Message 3 of 5

Anonymous
Not applicable
I do a similar thing in my vb.net application that finds my arx in all the processes that are running. I then can get that specific process. This is the code I am using, I don't know If you are using vb.net, but the process type is available to me in vb.net..


Dim Proc() As Process
Dim AcadProc As Process
Proc = process.GetProcessesByName("acad")
If Proc.Length >= 1 Then
For Each AcadProc In Proc
Dim obj As ProcessModule
For Each obj In AcadProc.Modules

If obj.ToString.EndsWith("(ArxNameHere.arx)") Then
NativeAcadHandle = AcadProc.Handle
MainAcadWindowHandle = AcadProc.MainWindowHandle()
AcadProcess = AcadProc
End If
Next
Next
End If


Hope it can help you.
0 Likes
Message 4 of 5

Anonymous
Not applicable
I do a similar thing in my vb.net application
that finds my arx in all the processes that are running. I then can get that specific process.
This is the code I am using, I don't know If you are
using vb.net, but the process type is available
to me in vb.net..

Dim Proc() As Process
Dim AcadProc As Process
Proc = process.GetProcessesByName("acad")

If Proc.Length >= 1 Then For Each AcadProc In Proc

Dim obj As ProcessModule

For Each obj In AcadProc.Modules

If obj.ToString.EndsWith("(ArxNameHere.arx)") Then
NativeAcadHandle = AcadProc.Handle
MainAcadWindowHandle = AcadProc.MainWindowHandle()
AcadProcess = AcadProc
End If
Next
Next
End If

Hope it can help you. (Just added some line feeds for clarity)
0 Likes
Message 5 of 5

Anonymous
Not applicable
Ok, sorry about the feeds
0 Likes