7. Handling of Scripting and Output Tools#

7.1 Scripting#

images/figura247_HANDLING_OF_SCRIPTING_AND_OUTPUT_TOOLS.png

NaxTo View contains an embedded Python console that allows the user to execute Python commands, launch Python scripts and execute application functions.

There are some functions developed for NaxToView that are thought to be executed from the scripting console. These will be explained below.

7.1.1. Basic Usage#

Most actions performed in NaxToView produce the equivalent action in the scripting window. For example, the action of selecting some elements in a model (with Item: Elements selected, shift + hold right click + select elements) automatically outputs a scripting command in the console.

images/figura248_HANDLING_OF_SCRIPTING_AND_OUTPUT_TOOLS.png

The command

“Session.Windows[0].Views[0].Scene.SelectionPicking.SelectGlobalIds(<…>)” appears. Notice that, if the user clears the selection and executes that command, the same elements will be selected.

images/figura249_HANDLING_OF_SCRIPTING_AND_OUTPUT_TOOLS.png Clear Botton

This can be useful to automate some actions. More complex tasks can be executed using File > Run Python Script

images/figura250_HANDLING_OF_SCRIPTING_AND_OUTPUT_TOOLS.png
Note:If the selection does not automatically appear, it is because the scene does not render the screen after a scripting command. Simply click on the model and the selection will appear.

7.1.2. Aplication Overview#

For most of the functionalities, it is important to understand the hierarchy of the application. This will help to use the methods intuitively and maneuver the commands as the GUI.

The command prompt has access to 2 scopes:

  • Command: it is a built-in way to execute scripts. For example:

images/figura251_HANDLING_OF_SCRIPTING_AND_OUTPUT_TOOLS.png
  • Session: it contains all the information and methods accessible by the user

The architecture overview is as follows:

images/figura252_HANDLING_OF_SCRIPTING_AND_OUTPUT_TOOLS.png

7.1.3. Detailed Functionality#

Loading a new model

  • Case 1: load from session (i.e. Application just started).

It creates a new Window, View, and Scene to store the model. If there is an existing Scene containing a model, it replaces it.

  • Case 2: session already created. Load model in certain view

  1. Create a new view in the first window. Session.Windows[0].Create View (“New view”)

  2. Load model in the newly created view. Session.Windows[0].Views[1].LoadModel1FEM(“ida22032//Models//wind3.op2)

Selection of elements and nodes

There are two ways of selecting entities in the application. The first one is using global ids (for internal use of the engine). The second option is the usage of solver ids. These are always composed of a superelement -or part- and an element/node id.

  • ID encoding: for ease of use, the application uses an encoding of ID ranges in a string format. The first part is composed of control charecters: ‘E’ or ‘N’ (element/node selection), ‘:’ and*‘S’* for solver selection. After these, the compressed string of ids. For each part/superelement, the string begins with ‘#Part_@’ and the ids. Each range is defined with :, and each group is split with ,. For example, ids 1,2,3,6,7,8 would be codified as “1:3,6:8”.

The following example selects elements 34750 to 34760, and 34800 to 34806: Session.Windows[0].Views[0].Scene.SelectionPicking.SelectGlobalIds(“E:S#Part_0@34750:34760,34800:34806”)

Creation of macros

NaxToView allows the creation of macros defined by the user. These macros allow the user to execute scripts directly from the application interface.

images/figura253_HANDLING_OF_SCRIPTING_AND_OUTPUT_TOOLS.png

In order to create a new macro, the script to execute must be stored in the macros folder of the installation of the program (By default, “C:\Program\IDAERO\NaxTo\NaxTo_\NAXTOVIEW\macros\”).

For example, if we want to create the macro “First macro” that executes the script “Test.py”, the first thing to do is to create “Test.py” and store it in the macros folder.

Then, the macro can be created with:

Session.CreateMacro(“First macro”, “Test.py”)

This will create the new macro and store it under macro_dict.xml, so it will be available the next time the program is executed.

Creation of buttons

Some interface elements, such as buttons, can be added by the user. In order to do this, a script with the action that the button performs must be included in the actions folder of the installation of the program (By default, “C:\Program\IDAERO\NaxTo\NaxTo_\NAXTOVIEW\actions\”).

Optionally, an icon can be assigned. To do this, add the icon in png format to the folder “icons” in the actions directory.

Then, the button can be created with:

Session.CreateButton(“NewButton”, “Test.py”, “Test.png”)

Notes:  
- The button name shall be only one word. CamelCase and underscores are allowed.
- If the icon parameter is left blank, the button name will be displayed instead.

This will create the new button and store it under action_dict.xml, so it will be available the next time the program is executed.

The button can then be moved around the toolbar by dragging it from the dotted vertical line to the left.

Loading scripts

The user can define actions to be performed after the application initialization. The desired commands should be added to the “autorun.py” script in the action’s directory (By default, “C:\Program\IDAERO\NaxTo\NaxTo_\NAXTOVIEW\actions\”). If a determined script is to be executed on load, it can be done using the command: Command.ExecuteScript(r”C:\path\to\script.py”)

7.2. Scripting IDE#

This powerful tool allows you to create and run Python scripts that execute inside NaxToView. It can range from simple scripts containing a few commands to the automatization of complex processes inside NaxToView creating your own interfaces and buttons.

The tool can be opened in three different ways:

Clicking on View > Scripting IDE

images/figura254_HANDLING_OF_SCRIPTING_AND_OUTPUT_TOOLS.png

Clicking on Tools > Macros > Create Macro

images/figura255_HANDLING_OF_SCRIPTING_AND_OUTPUT_TOOLS.png

Right clicking on the scripting window to open the tool with the code of the current session. In this example, the Scripting IDE has been opened with the same code as the

images/figura256_HANDLING_OF_SCRIPTING_AND_OUTPUT_TOOLS.png

In this example, the Scripting IDE has been opened with the same code as the session scripting window

images/figura257_HANDLING_OF_SCRIPTING_AND_OUTPUT_TOOLS.png

7.2.1. IDE controls#

The tool offers the following editing controls.

images/figura258_HANDLING_OF_SCRIPTING_AND_OUTPUT_TOOLS.png

images/figura259_HANDLING_OF_SCRIPTING_AND_OUTPUT_TOOLS.png Opens a new blank file, closing the current opened file.

images/figura260_HANDLING_OF_SCRIPTING_AND_OUTPUT_TOOLS.png Opens an existing file.

images/figura261_HANDLING_OF_SCRIPTING_AND_OUTPUT_TOOLS.png Saves the file.

images/figura262_HANDLING_OF_SCRIPTING_AND_OUTPUT_TOOLS.png Refresh: If the file is opened in another program, and it changes, this control updates the contents of the file.

images/figura263_HANDLING_OF_SCRIPTING_AND_OUTPUT_TOOLS.png Cut, Copy, and Paste.

images/figura264_HANDLING_OF_SCRIPTING_AND_OUTPUT_TOOLS.png Font Settings.

images/figura265_HANDLING_OF_SCRIPTING_AND_OUTPUT_TOOLS.png Indent right or left.

images/figura266_HANDLING_OF_SCRIPTING_AND_OUTPUT_TOOLS.png Run Script: Runs the script and executes every method and property into the current session.

7.2.2. Autocomplete#

The scripting IDE also comes with an autocomplete feature for every method and attribute that is inside Session and its children.

images/figura267_HANDLING_OF_SCRIPTING_AND_OUTPUT_TOOLS.png Method

images/figura268_HANDLING_OF_SCRIPTING_AND_OUTPUT_TOOLS.png Attribute

images/figura269_HANDLING_OF_SCRIPTING_AND_OUTPUT_TOOLS.png

Every time you press “.”, a dropdown will appear with the available methods or properties. In this case, the methods and properties available are related to a Window.

For each method or property there is documentation available when hovering the mouse over the name of the method or property in the dropdown.

images/figura270_HANDLING_OF_SCRIPTING_AND_OUTPUT_TOOLS.png

7.3. Output#

images/figura271_HANDLING_OF_SCRIPTING_AND_OUTPUT_TOOLS.png

The “Output” tool displays the output information for the selected elements, nodes, and coordinate systems. To start using the tool, follow these steps:

7.3.1. Plot Results and Make a Selection#

Select the elements, nodes, or coordinate systems you wish to analyze.

Once the selection is made, all results will be displayed in the Output table.

7.3.2. Customize Table Columns#

You can show or hide different columns in the table. To do this, access the “Filter Columns” section in the top left corner of the table.

images/figura272_HANDLING_OF_SCRIPTING_AND_OUTPUT_TOOLS.png

Simply check the columns you want to display and uncheck those you do not. You can filter by plot contour, element or node IDs, properties, materials, etc.

images/figura273_HANDLING_OF_SCRIPTING_AND_OUTPUT_TOOLS.png

You can also filter the information within each of these options.

7.3.3. Filter and Sort Values#

Clicking on the filter icon opens a dropdown menu that allows you to filter by values and sort them in ascending or descending order.

images/figura274_HANDLING_OF_SCRIPTING_AND_OUTPUT_TOOLS.png

Clicking the dropdown arrow allows you to filter by:

  • Equals

  • Does not Equal

  • Less tan

  • Less than or Equal

  • Greater tan

  • Greater than or Equal

  • Null

  • Not Null

images/figura275_HANDLING_OF_SCRIPTING_AND_OUTPUT_TOOLS.png

Enter the value in the box next to the arrow.

7.3.4. Export Data#

images/figura276_HANDLING_OF_SCRIPTING_AND_OUTPUT_TOOLS.png

You can export the visible information in the table in Excel, CSV, XML, or PDF format.

To do this, select the export format from the dropdown menu and click the corresponding icon.

images/figura277_HANDLING_OF_SCRIPTING_AND_OUTPUT_TOOLS.png Clicking this icon updates the selection of the model shown in the 3D view according to the table values. If any value is hidden in the table, clicking this icon will deselect those values in the model.

7.3.5. Coordinate Axes Visualization#

images/figura278_HANDLING_OF_SCRIPTING_AND_OUTPUT_TOOLS.png Element Coordinates Icon: Clicking this icon displays the coordinate axes of the selected elements. To hide them, click the icon again.

images/figura279_HANDLING_OF_SCRIPTING_AND_OUTPUT_TOOLS.png Material Coordinates Icon: Clicking this icon displays the coordinate axes of the materials of the selected elements. To hide them, click the icon again.

Zooming in on the selected elements allows you to see their coordinate axes.

images/figura280_HANDLING_OF_SCRIPTING_AND_OUTPUT_TOOLS.png The last icon is the Information icon. Clicking it opens this user guide in the same section.