11.1. Introduction to Scripts and Journals

Engineering Knowledge Manager

Administration Guide | Chapter 11: Scripts and Journals |

Chapter 11: Scripts and Journals |  | 11.2. Defining Scripts Using a Supported Scripting Language
Prev |  | Next

## 11.1. Introduction to Scripts and Journals

Let's begin by defining some terms.

macro

  A method defined in a supported language that can execute a sequence of tasks or call other macros. The arguments that a macro can be passed, and the values that it can return, will depend on the context in which it is used. Macros can be specified in separate script files or defined within process templates, lifecycles, custom types, and custom applications.

script

  A file that is written in the Python or BeanShell scripting language that contains one or more macros. BeanShell scripts have the .bsh extension; Python scripts have the .py extension.

journal

  A special type of script file that can be created using the Scripting menu in EKM through the recording of user interface actions. Also referred to as a journal script or a journal file. This is a Python file with extension .jou.py.

### Applications for Scripts in EKM

Some common applications for scripts in EKM are:

- Embedding scripts in process templates: You can embed scripts in process template XML files to:

  - Define logic that must be used in an expression but cannot be defined because it is too complex or you want to use reuse the logic in other ways.

  - Define logic for auto nodes. An auto node will execute the associated script upon activation.

  - Define custom dialog boxes for batch execution or task completion.

- Embedding scripts in lifecycle files: You can embed scripts in lifecycle XML files to:

  - Perform a validation before promotion or demotion the next or previous stage.

  - Execute an automated task after promotion or demotion.

- Embedding scripts in custom type files: You can embed scripts in custom type XML files to:

  - Add new action menus to built-in and custom types.

  - Define execution settings and update logic for analysis projects.

  - Define dependent properties (properties that depend on other properties) for any custom type. Example: The options available in a “state” property may be dependent on the value of a “country” property.

  - Define a macro that can be hooked to a custom type that will automatically execute whenever a new instance of that type is created.

- Embedding scripts in job template files: You can embed scripts in job template files to:

  - Define a macro for validating variable values entered by the user.

  - Define variables of type `Expression` whose value depends on other variables.

  - Define a custom dialog box for executing a job.

- Defining custom applications using a script file: You can use a script file to define a custom application. Two macros are needed in the file: an initialization macro that defines the variables used by the custom application to get user inputs, and an execution macro that processes the user inputs once they are submitted and executes some commands. See Defining and Using Custom Applications.

- Testing/debugging process templates: You can use scripts to launch a process from a given process template, and test tasks in the process. See Testing or Debugging a Process Template.

- Building a common script library: A common script library can be constructed by an EKM administrator to make its macros accessible to all users in all contexts. This is done by placing the script under workspace configuration control on the /Administration/Configuration/Scripts page. Once the script is placed in that location and the workspace configuration is accepted or applied, all of its macros will be accessible in all contexts: lifecycles, process templates, custom types, custom applications, and even the Command Window. On the other hand, macros defined in a specific context such as lifecycle file, are accessible only in that context. See the section on Configuring a Common Scripts Library in the Administration Guide for more details.

  Important: Scripts that are defined on the /Administration/Configuration/Scripts page cannot access the global `ekm` variable that is used in EKM's scripting interface. Therefore, this variable must be passed as an argument if a script is to make use of it.

Contains proprietary and confidential information of ANSYS, Inc. and its subsidiaries and affiliates.

Prev | Up / Contents | Next

Release 18.2 - © ANSYS, Inc. All rights reserved.