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.

NoteActiveX support in AutoLISP is limited to Windows only.

Create a new AutoLISP source code file

  1. In Visual LISP, click File New File.
  2. Click File Save As.
  3. In the Save As dialog box,
    • Specify a location for the new AutoLISP source file.
    • In the File Name box, enter interceptActiveXErrors.
    • In the Save As Type drop-down list, select Lisp Source Files.
    • Click Save.

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. Click Tools Load Text in Editor.
  2. At the AutoCAD Command prompt, enter (bnddrop) and press Enter.

    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