Skip to main content

KnowledgeBase

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.

scripting_editor.png
  1. Input field for scripting commands.

  2. Overview of all scripts saved in the .wbpz project.

  3. Creates a new script.

  4. Opens an external .wbps script file.

  5. Saves a script in the .wbpz project.

  6. Saves the script as an external .wbps script file.

  7. 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.

Figure 28. Structure of the master script
Structure of the master script

With a master script, external scripts can be organized in a directory structure. In the FVA-Workbench, only the master script is embedded using an #include command. Individual scripts can easily be commented out.



Figure 29. Embedding the master script
Embedding the master script

Only the master script is embedded in the FVA-Workbench with an #include command. It includes the references to all other scripts.

To embed the master script with a relative reference (as shown in the image), the file must be located in the global scripts directory.

The directory can be defined under Settings -> Directories -> Global scripts.



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

visual_studio_code.png

Representation of an FVA-Workbench script file in Visual Studio Code

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.

combo_attribute.png

"Allocation of addendum modification" combo attribute in the FVA-Workbench editor.

For combo attributes, an internal value list is stored, in which each option is assigned to exactly one value.

combo_attribute_overview.png

The attribute overview explains the value which corresponds to each selection.

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.

edat_rdat.png

Attribute EDAT values are copied into RDAT after a calculation.

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_overview.png

(1) Attributes can be filtered by component type.

(2) All attributes and components and their characteristics can be exported as an Excel file.

(3) Right-click to copy the attribute ID or component type.

(4) The current input (EDAT) and calculated (RDAT) values of an attribute can be queried.

Attribute Help

The Attribute Help provides a quick way to find the attribute ID, especially for input attributes.

f1_help.png

F1 opens the Attribute Help. Click the attribute name to show the help text for the attribute.