Looks like this code doesn't work in Autocad 2024.
*Moderator Edit* Post your code in a code window.
// Get a running instance of AutoCAD
try
{ acAppComObj = (AcadApplication)Marshal.GetActiveObject(strProgId);
}
catch // An error occurs if no instance is running
As referred in
https://help.autodesk.com/view/OARX/2024/ESP/?guid=GUID-C8C65D7A-EC3A-42D8-BF02-4B13C2EA1A4B
It works for older versions of Autocad but not for Autocad 2024.
Am I missing something? Any help?
Solved! Go to Solution.
Solved by ed57gmc. Go to Solution.
Are you sure that you are passing the correct value of strProgId?
From Help:
Super sure! My code is almost same as Autodesk sample. It doesn't work... any tip?
I'm running it from inside Autocad by the way.
Edited: Also this code was created around version 2017/18, and worked perfectly fine in old Autocad versions.
@josborneW959Y wrote:
Super sure! My code is almost same as Autodesk sample. It doesn't work... any tip?
The call should look like
{ acAppComObj = (AcadApplication)Marshal.GetActiveObject("AutoCAD.Application.24.3");
}
@josborneW959Y wrote:
I'm running it from inside Autocad by the way.
Why? You only need that if your code is running out-of-process. If your code is running inside acad, then you already know that the program is running. Just use the Application object or the AcadApplication object if you are using the COM api.
using acApp = Autodesk.AutoCAD.ApplicationServices.Application
using acadApp = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication
. . . and it never hurts if you name the variables for COM objects so they're easily identifiable and distinguishable.
// Called Kerry in my other life.
Everything will work just as you expect it to, unless your expectations are incorrect.
Sometimes the question is more important than the answer.
class keyThumper<T> : Lazy<T>; another Swamper
It worked... I forgot to update references, when I did old GetActiveObject also worked. My fault...
Thanks!!
Can't find what you're looking for? Ask the community or share your knowledge.