GUI 6.2.10

6.6. Script

newFASANT scripts are text files (in ASCII code) with ".nfs" extension that allow to save or load all the geometrical commands that have been run.

Two type of data are generated in script files:

  • Geometrical parameters defined that can be visualized within the Geometry- Parameters menu.
  • Geometric operation that have been performed that can be seen within the Edit -History menu.

By using this tool, a geometry that depends on multiple parameters may be generated and exported to be used in a different project with the same or even modified parameters. Use it whenever you need to set-up the configuration parameters of the existing geometry.

Be careful after loading an existing script, as the original units are not taken into account for the script loading/saving and the geometrical objects are generated in the working units.

6.6.1. Usage examples

This sections show an example of application of the scripts tool. We will show how to create a dihedral with parametric angle.

The Centimeters Units have been choosen and default Reference Plane is valid.

  • First step: Parameters definition. Click on Geometry - Parameters - Define Parameters menu, and create the parameters that are shown in the figure below.

parameters

Defined parameters

  • Second step: Geometry creation. The dihedral consists on two square planes that share a common edge, and the angle between them is given by the parameter angle that has been previously defined. The next figure show the commands performed to create the geometry.

commands

Commands that have been run to create a dihedral.

  • Third step: Script saving. Export the script by clicking on Tools - Script - Save menu.
  • Fourth stepScript visualization. Open the exported .nfs file with a text editor to visualize its content. Note that a new parameter (named $1) has been automatically generated for saving a mathematical operation. Edit the angle parameter, for example, change it from" [45.0,315.0] 7" to "[15.0,75.0] 5".
  • Fifth step: Script loading. Open a new instance of newFASANT. Note that a new instance is suggested to restart the default parameters (such as the Units) and remove both the History and the Defined Parameters. Click on Tools - Script - Load menu and select the modified script. Note that although the script was generated in Centimeters, the new geometry has been created in Meters, as they are the current working Units. Now, the angle of the new dihedral is set to 15 degrees, as it is the first value defined within the script file.

script_load

Modified script loading

A more complex example of script usage is available in Using-scripts-example.

6.6.2. Load

With this option the user can execute a list of commands written in a text file. The commands written in the file will be executed in order, one by one. This option is useful to ejecute a group of operations by a command.

Example, script that creates a geometry with copy and rotate commands:

#
#	newFASANT script file
# 
#       Copy this content to a .nfs file and load it.
#
box -n myGeometry -p -1.0 -1.0 0.0 2.0 2.0 2.0
move -s myGeometry -p 0.0 0.0 0.0 6.0 0.0 0.0
copy -s myGeometry -n myCopy -p 0.0 0.0 0.0 0.0 0.0 0.0
rotate -s myGeometry -p 0.0 0.0 0.0 0.0 0.0 1.0 45.0
copy -s myGeometry -n myCopy -p 0.0 0.0 0.0 0.0 0.0 0.0
rotate -s myGeometry -p 0.0 0.0 0.0 0.0 0.0 1.0 45.0
copy -s myGeometry -n myCopy -p 0.0 0.0 0.0 0.0 0.0 0.0
rotate -s myGeometry -p 0.0 0.0 0.0 0.0 0.0 1.0 45.0
copy -s myGeometry -n myCopy -p 0.0 0.0 0.0 0.0 0.0 0.0
rotate -s myGeometry -p 0.0 0.0 0.0 0.0 0.0 1.0 45.0
copy -s myGeometry -n myCopy -p 0.0 0.0 0.0 0.0 0.0 0.0
rotate -s myGeometry -p 0.0 0.0 0.0 0.0 0.0 1.0 45.0
copy -s myGeometry -n myCopy -p 0.0 0.0 0.0 0.0 0.0 0.0
rotate -s myGeometry -p 0.0 0.0 0.0 0.0 0.0 1.0 45.0
copy -s myGeometry -n myCopy -p 0.0 0.0 0.0 0.0 0.0 0.0
rotate -s myGeometry -p 0.0 0.0 0.0 0.0 0.0 1.0 45.0
copy -s myGeometry -n myCopy -p 0.0 0.0 0.0 0.0 0.0 0.0
rotate -s myGeometry -p 0.0 0.0 0.0 0.0 0.0 1.0 45.0
#
#    End script file
#

Results of the previous script.

Geometry after loading the script

6.6.3. Save

The user can export all executed commands with this option. To see a list of executed commands, enter into the menu EditHistory.

6.6.4. Advanced description

This section is detailed for advanced users that need to write the scripts by themselves. After reading this section, the user may be able to understand the script examples available in section Scripts and User Functions Center.

Regarding general information about newFASANT scripts, the next considerations must be taken into account:

  • Blank lines may be inserted to get a more readable file.
  • Comments start with "#" character. Every sentences of the current line that are written after this character will be omited. 
  • Every line run a new order. However, a line may be split in so many lines as desired, as stated in the below specification.
  • Character " \" is the Escape character, so the next character will be omitted. It is usually inserted to split an order in multiple lines and then to obtain a more readable file.
  • Order lines start with the command name.

The following specifications are applied to most of commands that may be loaded in script files:

  • set command creates new parameters, specified by its name and values (it may be fixed values, range values or even functions)
  • -n option set the output name of the resulting elements within the current command. Be careful to provide unique names to every command; otherwise the console will not load the script after detecting repeated output names.
  • -s option list the selected objects as input arguments to the current command. It is used in commands that require the selection of objects as input.
  • -p option list the required parameters for the current command.
  • -t option list the transformation matrix of the reference plane required for using the current command. It is the next 4x4 matrix with the below specifications:
  column0 column1 column2 column3
row0 m00 m01 m02 m03
row1 m10 m11 m12 m13
row2 m20 m21 m22 m23
row3 m30 m31 m32 m33
    • the matrix is written in rows as: -t m00 m01 m02 m03 m10 m11 m12 m13 m20 m21 m22 m23 m30 m31 m32 m33
    • the elements m00 m10 m20 within column0 defines the X unitary vector-direction of the reference plane.
    • the elements m01 m11 m22 within column1 defines the Y unitary vector-direction of the reference plane.
    • the elements m02 m12 m22 within column2 defines the Z unitary vector-direction of the reference plane.
    • the elements m00 m10 m20 within column3 defines the X Y Z point where the reference plane is centered.
    • the elements m30 m31 m32 m33 within row3 are always set to 0 0 0 1 respectively.
  • -c option is only available in some commands, and it may be used with different purposes:
    • It indicates that the current command will generate a copy of the input objects. It may be used in commands such as: symmetric,...
    • It indicates that the current command will generated a closed object. Otherwise, only the side surfaces are generated. It may be used in commands such as: cylinder, cone, ogive,...
    • It indicates that the current command will have cutting objects that will not be modified. It is only used in split options, such as splitSurfaces, splitCurves,...

We use cookies on this website to improve your navigation experience on this site. By using this site, you agree to our cookie policy.

I agree