GetObject is not working in 2025 Beta Version

GetObject is not working in 2025 Beta Version

serpetfree
Contributor Contributor
2,041 Views
7 Replies
Message 1 of 8

GetObject is not working in 2025 Beta Version

serpetfree
Contributor
Contributor
Hi,
I need some help.
I've downloaded Civil 3D Vail (2025 Beta version). I've created a simple .NET 8.0 Plugin for AutoCAD 2025. (ClassLibrary)
 
Here my code:
     <Autodesk.AutoCAD.Runtime.CommandMethod("Testgetobject")>
     Public Sub Testgetobject()
          Dim acAppComObj As Autodesk.AutoCAD.Interop.AcadApplication
          Dim strProgId As String = "AutoCAD.Application.25"
          acAppComObj = GetObject(, strProgId)
                  If acAppComObj Is Nothing Then
                                     MsgBox("acAppComObj is Nothing")
                   else
                                      MsgBox(acAppComObj.ActiveDocument.Name)
                   End if
     End Sub
 
    acAppComObj is Nothing, GetObject is not working
   
    Can anyone help? Why is it not working?
    Thanks.
0 Likes
2,042 Views
7 Replies
Replies (7)
Message 2 of 8

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

should be placed as feedback in the beta-forum.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 3 of 8

ntclmain
Advocate
Advocate

Now AutoCAD 2025 is released, I think the topic can be opened again.

*

I got the same error with .Net 8, AutoCAD 2025:

     Interaction.GetObject(, "Excel.Application")

return Nothing 

As describe here for .Net 8,  

https://learn.microsoft.com/en-us/dotnet/api/microsoft.visualbasic.interaction.getobject?view=net-8....

Interaction.GetObject(, "Excel.Application") should return an opening Excel instance (if any). In fact, it returns Nothing in all cases.

 

Are there anyone got the same error?

 

0 Likes
Message 4 of 8

saviour_merlin
Community Visitor
Community Visitor

We have been using following strings in Autocad 2024 successfully.string progID = "AutoCAD.Application.24.
AcadApplication = (AcadApplication)Marshal.GetActiveObject(progID);
We have downloaded Autocad Architectural 2025 trial version. GetActiveObject is not working it is throwing an Exception.
If I use string progID = "AutoCAD.Application.25";
It throws the exception as
Unable to cast COM object of type 'System.__ComObject' to interface type 'AutoCAD.AcadApplication'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{52EE1CD2-A793-4DEC-9DF9-71CE75881F05}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).Please enable GetActiveObject string for 2025.

0 Likes
Message 5 of 8

_gile
Consultant
Consultant

Hi,

Marshal.GetActiveobject is only available with .NET Framework (see the bottom of this page).



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 6 of 8

saviour_merlin
Community Visitor
Community Visitor

Yes u r right. While I am using my WCF Service it is not working in Autocad 2025. Still Autocad 2024 it was working fine. In Autocad 2025 it is not recognizing the string.

string progID = "AutoCAD.Application.24."
AcadApplication = (AcadApplication)Marshal.GetActiveObject(progID); It throws exception as string

not available

0 Likes
Message 7 of 8

daniel_cadext
Advisor
Advisor

Just an FYI, progID   'AutoCAD.Application.25' works from python, so its probably something wrong with .NET or your installation

 

 

def PyRxCmd_doit():
    try:
        axApp = Ax.getApp()
        print(axApp.FullName)
    except Exception as err:
        traceback.print_exception(err)

#result      
#C:\Program Files\Autodesk\AutoCAD 2025\acad.exe
        
##wrappers
#
# def getApp() -> IAcadApplication:
#     id = AcadApplication.CLSID
#     return win32com.client.GetActiveObject(id)
   
# # This CoClass is known by the name 'AutoCAD.Application.25'
# class AcadApplication(CoClassBaseClass): # A CoClass
#     # An instance of the AutoCAD application
#     CLSID = IID('{363E5B47-885D-44C3-89EB-A2AB2129B57E}')
#     coclass_sources = [
#         _DAcadApplicationEvents,
#     ]
#     default_source = _DAcadApplicationEvents
#     coclass_interfaces = [
#         IAcadApplication,
#     ]
#     default_interface = IAcadApplication 
    

 

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
0 Likes
Message 8 of 8

_gile
Consultant
Consultant

It seems possible to P/Invoke GetActiveObject, see this topic.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub