Author Topic: ZOOM EXTENTS from C#  (Read 6694 times)

0 Members and 1 Guest are viewing this topic.

HD

  • Guest
ZOOM EXTENTS from C#
« on: January 25, 2006, 02:40:31 PM »
Hi!


I was trying to do a ZOOM EXTENTS from C# and I ran across the following example:

AcadApplication pApp;

pApp = (Autodesk.AutoCAD.Interop.AcadApplication)Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication;

pApp.ZoomExtents();

Would someone please explain the "pApp = (Autodesk.AutoCAD........)" statement.


Thank You!


Draftek

  • Guest
Re: ZOOM EXTENTS from C#
« Reply #1 on: January 25, 2006, 03:52:24 PM »
The pApp AcadApplication is the ComInterop library version of the autocad application. What is available in the .Net dll is the managed class object.

The code is performing a cast conversion of the managed AcadApplication object to the interop object.

Not everthing is available in the managed classes yet, so you have to use some com interop to get the job done.

MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: ZOOM EXTENTS from C#
« Reply #2 on: January 25, 2006, 04:27:23 PM »
Just to expand on what Draftek was saying -
AcadApplication pApp ---> this is a pointer (a place to store the address of) to the running applicaction in memory.

Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication --> this is a function of the current running application (you are 'hooked' to with your dll) that returns this pointer.

and
(Autodesk.AutoCAD.Interop.AcadApplication) --> this is a cast which basically makes sure that the passed pointer does indeed point to an application object and sets it up for use with the COM interface of pApp. (that explanation will do for now anyway)

Once you have your pApp you can call its member functions to do what you need using this COM interface.

hth.
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

Draftek

  • Guest
Re: ZOOM EXTENTS from C#
« Reply #3 on: January 25, 2006, 04:55:25 PM »
nice clean up, Mick.

You write more concise than I think...