.NET

Reply
Contributor
glanard
Posts: 20
Registered: ‎09-29-2006
Message 1 of 3 (239 Views)

Interop 32/64 COM - Acad Mechanical

239 Views, 2 Replies
12-12-2012 11:38 PM

Hi,

 

Here is my sample code with the context: .Net Framework 4 / AnyCpu / ObjectArx2012:

________________________________________________________________________

Imports Autodesk.AutoCAD.Runtime

Imports SymBBAuto

Imports clsAcadApp = Autodesk.AutoCAD.ApplicationServices.Application

 

Public ClassClass1

<CommandMethod("TestAcadm")>

 Public Sub cmdTestAcadm()

      Dim AcadInterface As Autodesk.AutoCAD.Interop.AcadApplication

      AcadInterface =clsAcadApp.AcadApplication

 

  Dim SymBBInterface AsMcadSymbolBBMgr

     SymBBInterface = AcadInterface.GetInterfaceObject("SymBBAuto.McadSymbolBBMgr.3")

     MsgBox(SymBBInterface.StandardMgr.CurrentStandardName)

EndSub

 

<CommandMethod("TestAcadm2")>

Public Sub cmdTestAcadm2()

   Dim AcadInterface As Autodesk.AutoCAD.Interop.AcadApplication

       AcadInterface =clsAcadApp.AcadApplication

 

   Dim SymBBInterface AsMcadSymbolBBMgr

   Try

             SymBBInterface = AcadInterface.GetInterfaceObject("SymBBAuto.McadSymbolBBMgr.3")

       Catch ex AsException

             MsgBox("Error with: <SymBBAuto.McadSymbolBBMgr.3>." & vbCr & ex.Message)

       EndTry

EndSub

 

End Class

________________________________________________________________________

 

  • First of all, if I add a reference to …\ObjectARX 2012\inc-win32\Autodesk.AutoCAD.Interop.dll, so this will work fine for Acad / AcadM 2012 on XP 32bits, but not on Seven 64bits.

 

If I replace this reference with …\ObjectARX 2012\inc-x64\Autodesk.AutoCAD.Interop.dll, this will work fine for Acad / AcadM 2012 on Seven 64bits, but not on XP 32bits.

 

So, my first question, do I need to create 2 solutions in Visual Studio, the first one referencing the win32 Interop and the second one referencing the x64 Interop? Isn't it possible to have only one solution for either 32 or 64 bits OS?

 

  • As you can see in the second Sub, the "Try-Catch" is just there to "detect" if we are on just AutoCAD (error) or AutoCAD Mechanical (no error) :smileytongue:

Is there a better solution to detect if we are really in the Mechanical Release, or to detect if the COM (here SymBB) is loaded?

 

Thanks a lot for your answers,

*Expert Elite*
_gile
Posts: 2,084
Registered: ‎04-29-2006
Message 2 of 3 (234 Views)

Re : Interop 32/64 COM - Acad Mechanical

12-13-2012 12:06 AM in reply to: glanard

Hi,

 

While referencing Autodesk.AutoCAD.Interop you'll have to build two different assembly.

The only way I know to avoid this is using late binding (or dynamic type if targeting the Framework 4) where the main inconvenient is the loose of intellisense and edition/complation errors which will throw at execution time.

You can create and debug your app using Autodesk.AutoCAD.Interop reference and when it's done, replace all COM types with Object (or dynamic) type and release the Interop reference.

Gilles Chanteau
Contributor
glanard
Posts: 20
Registered: ‎09-29-2006
Message 3 of 3 (231 Views)

Re: Interop 32/64 COM - Acad Mechanical

12-13-2012 12:18 AM in reply to: glanard

Hi Gilles,

 

I suppose you're french, me too :smileyhappy:

 

Well, I had an idea and it seems to work^^

 

Referencing any of the win32 or x64 Interop, I change its property "Incorporer les types Interop" to False (and "Copie locale" to False) and my (same) DLL works fine either on XP32 or Seven 64!!

 

So, for me it's a good news, if anyone can confirm that there is no restriction doing this?

 

I know I will have to manage some things like ObjectID and ObjectID32, but this is just some "If... then...".

 

++

 

Edit: There is still the question: how to detect we are in "Mechanical", with the SymBB COM loaded...

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.