Access .NET from the COM application object?

Access .NET from the COM application object?

Anonymous
Not applicable
1,388 Views
9 Replies
Message 1 of 10

Access .NET from the COM application object?

Anonymous
Not applicable

Does anyone know if it is possible to access .NET from the COM application object?

 

I have a stand alone application that accesses the Autodesk.AutoCAD.Interop.AcadApplication object and uses it for various functions.

What I would like to do is to access objects in the .NET namespaces Autodesk.AutoCAD.Runtime,  Autodesk.AutoCAD,Applicationservices,  Autodesk.AutoCAD.Editorinput etc. via the COM-application object.

 

Is that possible?

 

Regards

Jan Grenov

 

0 Likes
Accepted solutions (1)
1,389 Views
9 Replies
Replies (9)
Message 2 of 10

augusto.goncalves
Alumni
Alumni
Accepted solution

Hi Jan,

 

No you cannot. The namespaces available under AcMgd and AcDbMgd are for in-process only, meaning just for plug-ins (not external applications).

 

The alternative is expose what you need to an outside caller using the approach suggested here:

 

http://through-the-interface.typepad.com/through_the_interface/2009/05/interfacing-an-external-com-a...

 

Hope this explains.

 

Augusto Goncalve

Autodesk Developer Network

Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
0 Likes
Message 3 of 10

Anonymous
Not applicable

Hi Augusto

 

OK. Thanks a lot for your answer. I'll study the alternative that you proposed.

 

 

0 Likes
Message 4 of 10

Anonymous
Not applicable

I know you have an answer.

I looked at the answer, but it was beyond me.

Perhaps I can give you another solution, which I think is easier to understand and depends on some very basic code.

 

Insert a timer in your external application, the sole function of which is to poll for the existance of a file.

Decide what data you wish to have in this file.

Read the file and then delete it.

 

In your Inprocess class, write data to this file.

 

Experiment with the timing of your timer.

I have found it can be very quick.

0 Likes
Message 5 of 10

Anonymous
Not applicable

Not a bad idea.

Thanks for sharing it 🙂

0 Likes
Message 6 of 10

Hallex
Advisor
Advisor

I have not tried to use Timer

Can you share a simple code with

TIA

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
0 Likes
Message 7 of 10

Anonymous
Not applicable

 

Well this is not really a timer, but it works fine for me:

 

Dim cnt As Short = 0

Dim AcadIsReady As Boolean

 

While Not AcadIsReady

   Try

      If cnt > 10 Then' After ten attempts ...

              MsgBox("Send some error message")

              Exit Sub

      Else

         Try to execute your in-process-function here ' This will fail as long as AutoCAD is busy

         AcadIsReady = True

      End If

   Catch ex As Exception

      cnt = cnt + 1

          System.Threading.Thread.Sleep(1000) ' Sleep for one second

   End Try

End While

0 Likes
Message 8 of 10

Hallex
Advisor
Advisor

Thanks a lot

Regards,

 

Oleg

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
0 Likes
Message 9 of 10

Anonymous
Not applicable

I am assuming that you have an exe that needs to read events raised in an inprocess dll (referencing acdbmg)

So instead of raing an event which Im not sure how you might do it, write to a file with a message.

 

In your app, the timer event simply waits for the File.Exists(yourfilename) to return True. The read it and from its message work out what the event was intended to be.

0 Likes
Message 10 of 10

Hallex
Advisor
Advisor

Thanks for exoalnation

It's clearly enough,

Regards 🙂

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
0 Likes