Example: Intercept an Error Returned by an ActiveX Method (AutoLISP/ActiveX)

The vl-catch-all-apply function allows you to intercept errors returned by ActiveX methods, and decide how the program should continue.

Note: ActiveX support in AutoLISP is limited to Windows only.

Create a new AutoLISP source code file

Create a new Ray object in model space

Get the bounding box for the last object added to model space

Load and run the code

  1. Save the LSP file and then load it into AutoCAD.
  2. At the AutoCAD Command prompt, enter (bnddrop).

    Because a Ray object extends to infinity, it is not possible to enclose it with a box, and GetBoundingBox results in the following error:

    ; error: Automation Error. Invalid extents

    If this code were part of your application program, execution would halt at this point.

Catch the error created by the vla-GetBounding Box function