The ENVI Extension Wizard allows you to create an IDL project that can added as a custom extension to ENVI. Custom ENVI extensions will appear in the ENVI Toolbox.

The steps to build an ENVI extension are:

  1. Use the ENVI Extension Wizard to create an IDL project and a corresponding IDL .pro file that contains the extension template code.
  2. Edit the extension code to perform the desired actions when the extension is invoked. See the ENVI Help topic Writing and Deploying Toolbox Extensions for details.
  3. In the IDL Workbench Project menu, or in the right-click menu in the Project Explorer, select Build Project. This will compile all of the required IDL code, and create an IDL SAVE file in the chosen extension directory. See Building IDL Projects for more information.
  4. Launch the ENVI application. Your new extension should appear in the ENVI Toolbox. Double-click your extension to execute your code.

Note: If you have already run ENVI in the same session, you should execute a .RESET_SESSION command before restarting ENVI, to ensure that your new extension is loaded.

ENVI Extension Wizard Dialog


To open the ENVI Extension Wizard, select File > New ENVI Extension from the IDL Workbench main menu, or right-click in the Project Explorer and select New ENVI Extension.

Complete the following fields:

Project Name: Enter the IDL project name for the new extension. The project name must be unique. See Projects for details.

Extension Name: Enter the name of the extension as you want it to appear in the ENVI Extensions Toolbox.

IDL Procedure: Enter the name of the IDL procedure to run when the extension is run. This must be a valid IDL procedure name. This will also be used as the name of the .pro file that will be created.

Extension Path: Enter the path under the Extensions folder where you want the extension to appear in the ENVI Toolbox. If the Extension Path is empty, the item will be added directly to the end of the Extensions folder. You can specify multiple subfolders by adding the '/' character between folder names (for example, "My Routines/Statistics"). If a folder does not currently exist, it will be created.

Save File Location: Enter the location where the IDL SAVE file should be created when the project is built (see Building IDL Projects). ENVI looks in three locations for extensions:

  • The directory given by the ENVI_EXTENSIONS environment variable
  • The install directory: InstallDir/products/enviextensions
  • The user's home directory:user_home/.idl/CompanyName/enviextensions

If left empty, this field is set to the user's home directory. After the IDL project has been created, you can go to the IDL Build Properties page to modify the SAVE file location.

Customizing the ENVI Extension Code


After you run the ENVI Extension Wizard, a new IDL editor opens, containing the extension code. The extension name, IDL procedure name, and extension path are automatically added to the code.

By default, the extension file contains an "_extensions_init" procedure at the top, followed by the actual extension procedure. The extension procedure has a section of generic error-handling code, and then a line of code to retrieve the current ENVI application object. Finally, you should insert your custom extension code near the bottom of the file, after the IDL comment block marked "Insert your ENVI Extension code here...".

You can modify the default extension template code that is inserted. To modify the template, open the Preferences dialog in the IDL Workbench. In the Preferences dialog, choose IDL >Templates, and edit the ENVIExtension template to contain your desired code. The following custom variables are available:

Variable

Description

${EXTENSION_NAME}

The ENVI Extension name from the Wizard

${PROCEDURE_NAME}

The IDL Procedure name from the Wizard

${EXTENSION_PATH}

The Extension Path value from the Wizard

In addition, you can also use any of the other IDL template variables, such as ${date}, ${time}, ${user}, or ${year}.

The extension can also accept an event argument that contains the UVALUE set during the call to ENVI::AddExtension.