General
Scripting Editor
Scripts are created and executed using the Scripting Editor. To access the Editor, click Extras -> Scripting. Scripts can be saved directly in the .wbpz project file or exported as a separate .wbps file.
Input field for scripting commands.
Overview of all scripts saved in the .wbpz project.
Creates a new script.
Opens an external .wbps script file.
Saves a script in the .wbpz project.
Saves the script as an external .wbps script file.
Runs the current script.
Embedding external scripts
External scripts can be embedded using the #include command. This makes it possible to store frequently used features in separate .wbjs files and integrate them into the main script. Multiple #include commands can be can be run in succession. Embedding is usually done at the beginning of the main script. If you wish to include multiple external scripts, it is recommended to create a MasterScript.wbjs file. This includes multiple #include commands and the paths for the individual scripts. Only the master script needs to be included in the scripting view of the FVA-Workbench.
Using a development environment
A development environment (IDE) can also be used to create scripts instead of the FVA-Workbench's integrated Scripting Editor. IDEs are specialized software tools that make it easier to create code.
To test changes to a script directly in the FVA-Workbench, the scripts should be saved in separate .wbjs files and embedded using #include commands. See Embedding external scripts
Advantages include:
Syntax highlighting
Code formatting
Automatic commenting in/out of code lines
The following open-source development environments are suitable for editing FVA-Workbench scripts:
Visual Studio Code
Notepad++
WebStorm
FVA-Workbench scripts are written in JavaScript and have the file extension .wbjs. Not all development environments recognize .wbjs files as JavaScript. In order to display syntax highlighting and other convenient features, the programming language must be manually defined.
Data types
User inputs and calculation results are stored in attributes with the following data types:
Data type | Type identifier | Data | Example attribute (ID) |
---|---|---|---|
Logical value | Boolean | true or false | use_fem_part (Consider FEM stiffness) |
Number | Double | 3.14159 | iso 6336 application factor (application factor) |
Number with unit | TechValue | 3.14159 mm | center_distance (center distance) |
Character string | String | "This is text" | comp_remarks (component notes) |
List | Array | [0.12, 2.34, 7.83, 2.33] | force in mesh direction (load distribution across the face width ) |
List of lists | Matrix | [ [1.2, 3.0, 4.6], [0.2, 6.4, 2.1], [3.1, 1.5, 9.5] ] | result_matrix_pressure_distribution_values (pressure distribution) |
Special case: combo attributes
The FVA-Workbench input editor includes many drop-down lists, where the user can select from several options. This selection is stored in so-called combo attributes. These combo attributes can be either string, integer, or double data types.
For combo attributes, an internal value list is stored, in which each option is assigned to exactly one value.
setAttr("ratio_X1_X2", stageID, 6, EDAT);
Example script: sets "Allocation of addendum modification" combo attribute to a value of 6 for "uniform rolling contact pressure."
Data integrity (EDAT/RDAT)
Every attribute includes two different values: an input value (EDAT) and a calculated value (RDAT). If the user specifies a value in the editor, the EDAT value of the attribute is set. When a calculation is performed, the EDAT value is copied and written to RDAT.
Attributes that are purely calculation results and are not specified by the user also have an EDAT and RDAT value. The EDAT value for these attributes is always empty. After a calculation, the result is written to the RDAT.
The RDAT value of an attribute is therefore either a copy of the EDAT value or a calculation result. In most cases, the EDAT value of an attribute is set in scripting.
Finding attributes
There are several thousand attributes in the FVA-Workbench in which inputs and results are saved. These attributes can be read or set in scripting using the setAttr() function.
The FVA-Workbench includes many options for finding the correct attribute from the multitudes.
Attribute overview
Menu -> Extras -> Attribute overview
Attribute Help
The Attribute Help provides a quick way to find the attribute ID, especially for input attributes.