.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Interop 32/64 COM - Acad Mechanical

2 REPLIES 2
Reply
Message 1 of 3
glanard
523 Views, 2 Replies

Interop 32/64 COM - Acad Mechanical

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) Smiley Tongue

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,

2 REPLIES 2
Message 2 of 3
_gile
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
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 3
glanard
in reply to: glanard

Hi Gilles,

 

I suppose you're french, me too Smiley Happy

 

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...

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost