3

I'm trying to write a method to zoom to the extents of a drawing in AutoCAD using C#.NET and the latest version of ObjectARX. I googled for an example of someone doing that and found this post which has the following method:

[CommandMethod("zoomExtentTest")]
public static void zoomExtentTest()
{
    //using InvokeMember to support .NET 3.5
    Object acadObject = Application.AcadApplication;
    acadObject.GetType().InvokeMember("ZoomExtents", BindingFlags.InvokeMethod, null, acadObject, null);
}

When I tried to copy the code I got an error saying Autodesk.AutoCAD.ApplicationServices.Application has no defintion for AcadApplication so I'm guessing it got replaced with something else but I don't know where I'd find such a replacement or how I'd rewrite the above method to work with the current AutoCAD .NET API.

Nick Gilbert
  • 4,159
  • 8
  • 43
  • 90

1 Answers1

1

Looks like you're missing the AcMgd.dll reference, can you check it?

If you plan to use this with AutoCAD Console, it's not possible: the COM API is not available on AutoCAD Console nor AutoCAD I/O

Augusto Goncalves
  • 8,493
  • 2
  • 17
  • 44
  • I added all my references via AutoCAD's NuGet packages which include AcMgd.dll. Would I have to put a using statement at the top of my code? – Nick Gilbert Jul 17 '15 at 16:08
  • Figured out what happened, I was using Autodesk.AutoCAD.ApplicationServices.Core.Application instead of Autodesk.AutoCAD.ApplicationServices.Application. This answer helped me figure that out so I'll accept it – Nick Gilbert Jul 17 '15 at 16:41
  • Nice catch! Indeed the .Core namespace is from AcCoreMgd.dll, so no COM (AcadXxxxx) objects – Augusto Goncalves Jul 17 '15 at 17:09