API Reference#

This is the list of all commands available in the NaxToView Scripting package.

Attributes commands#

NaxToView functions to create, import, and plot attributes in the active view.

n2vscripting.attributes.create_attribute(name: str, att_type: Literal['Node', 'Element', 'ElementNodal'], formula: str) None#

Create a new attribute in the active view as a combination of other attributes.

Parameters:
  • name (str) – The name of the attribute to create.

  • att_type (str) – The type of item the attribute applies to. Default is ‘Node’, other options are ‘Element’ and ‘ElementNodal’.

  • formula (str) – The formula used to define the attribute.

Examples

>>> n2v.create_attribute('MyAttribute', 'Node', '<attribute1> + <attribute2>')
n2vscripting.attributes.create_attribute_from_contour() None#

Create an attribute from the current contour plot in the active view.

n2vscripting.attributes.import_attributes(file_path: str) None#

Import attributes from a .csv file into the active view.

Parameters:

file_path (str) – Path to the input .csv file

Examples

>>> n2v.import_attributes("C:/path/to/attributes.csv")
n2vscripting.attributes.plot_attribute(name: str) None#

Plot the specified attribute as a contour in the active view.

Parameters:

name (str) – The name of the attribute to plot.

Examples

>>> n2v.plot_attribute('MyAttribute')

Camera commands#

NaxToView functions to control the camera in the active view.

n2vscripting.camera.change_camera_distance(value: float) None#

Change distance parameter of the camera on the active view.

Parameters:

value (float) – Distance parameter.

Examples

>>> n2v.change_camera_distance(10.0)
n2vscripting.camera.change_clipping_range(lower: float, upper: float) None#

Change the clipping range of the camera on the active view.

Parameters:
  • lower (float) – Lower limit of the clipping range.

  • upper (float) – Upper limit of the clipping range.

Examples

>>> n2v.change_clipping_range(0.1, 100.0)
n2vscripting.camera.change_focal_point(x: float, y: float, z: float) None#

Change the focal point of the camera on the active view.

Parameters:
  • x (float) – X coordinate of the focal point.

  • y (float) – Y coordinate of the focal point.

  • z (float) – Z coordinate of the focal point.

Examples

>>> n2v.change_focal_point(0.0, 0.0, 0.0)
n2vscripting.camera.change_parallel_scale(value: float) None#

Change the parallel scale value of the camera on the active view.

Parameters:

value (float) – Parallel scale value.

Examples

>>> n2v.change_parallel_scale(1.0)
n2vscripting.camera.change_position(x: float, y: float, z: float) None#

Change the position of the camera on the active view.

Parameters:
  • x (float) – X coordinate of the position.

  • y (float) – Y coordinate of the position.

  • z (float) – Z coordinate of the position.

Examples

>>> n2v.change_position(0.0, 0.0, 0.0)
n2vscripting.camera.change_view_angle(value: float) None#

Change angle of the camera on the active view.

Parameters:

value (float) – View angle

Examples

>>> n2v.change_view_angle(30.0)
n2vscripting.camera.change_view_up(x: float, y: float, z: float) None#

Change the reference upwards direction of the camera on the active view.

Parameters:
  • x (float) – X component of the direction vector.

  • y (float) – Y component of the direction vector.

  • z (float) – Z component of the direction vector.

Examples

>>> n2v.change_view_up(0.0, 1.0, 0.0)
n2vscripting.camera.select_viewpoint(view: Literal[0, 1, 2, 3, 4, 5, 6]) None#

Select a view point from the 7 default views available.

Parameters:

view (int) –

id of the view. Available options are:
  • 0 -> Isometric view

  • 1 -> X-Y plane. X right, Y up.

  • 2 -> X-Z plane. X left, Z up.

  • 3 -> X-Y plane. X right, Y down.

  • 4 -> Y-Z plane. Y left, Z up.

  • 5 -> X-Z plane. X right, Z up.

  • 6 -> Y-Z plane. Y right, Z up.

Examples

>>> # To change to isometric view
>>> n2v.select_viewpoint(0)
>>> # To change to X-Y plane view, with X right and Y up
>>> n2v.select_viewpoint(1)

Utility commands#

n2vscripting.common.change_active_view(view: int) None#

Change the active view.

Parameters:

view (int) – Index of the view to be activated. Must be between 0 and the number of views - 1.

Examples

>>> n2v.change_active_view(1)
n2vscripting.common.create_view(name: str) None#

Create a new view in the active window.

Parameters:

name (str) – Name of the new view. Must be unique.

Examples

>>> n2v.create_view('MyNewView')
n2vscripting.common.get_active_scene()#

Get the scene from the active view.

n2vscripting.common.get_lcs_list()#

Get the list of load cases in the active view.

n2vscripting.common.hide_connectors() None#

Hide connectors in the active view.

n2vscripting.common.import_results(results_files: list[str]) None#

Import results from a results file.

Parameters:

results_files (list[str]) – A list of paths to results files.

Examples

>>> n2v.import_results(['C:/path/to/results1.op2', 'C:/path/to/results2.op2'])
n2vscripting.common.load_model(file_path: str) None#

Load model from a file. If it is a results file, load results as well

Parameters:

file_path (str) – Path to the model file.

Examples

>>> n2v.load_model('C:/path/to/model.op2')
>>> n2v.load_model('C:/path/to/model.bdf')
n2vscripting.common.take_screenshot(file_path: str, background: str = 'White', file_format: str = 'PNG') None#

Take a screenshot of the current view and save it to a file.

Parameters:
  • file_path (str) – Save file path.

  • background (str, optional) – Background color of the screenshot. Options are: ‘White’, ‘Current’ and ‘Transparent’. Default is ‘White’.

  • file_format (str, optional) – Format of the save file. Options are ‘PNG’ and ‘JPG’. Default is ‘PNG’.

Examples

>>> n2v.take_screenshot('C:/path/to/screenshot.png')
>>> n2v.take_screenshot('C:/path/to/screenshot.jpg', background='Transparent')
>>> n2v.take_screenshot('C:/path/to/screenshot.jpg', background='Current', file_format='JPG')

Derived Results commands#

This module contains all functions related to derived load cases and results in NaxToView.

n2vscripting.derived.create_derived_component(name: str, formula: str, result: str) None#

Create a new derived component in the active scene.

Parameters:
  • name (str) – Name of the new derived component.

  • formula (str) – Formula of the derived component.

  • result (str) – Result from which the components in the formula are taken.

Examples

>>> # Create a new derived stresses component
>>> n2v.create_derived_component('MyDerivedStress', '<CMPT_STRESSES:XX>+<CMPT_STRESSES:YY>', 'STRESSES')
n2vscripting.derived.create_derived_lc(name: str, formula: str) None#

Create a new derived load case in the active scene.

Parameters:
  • name (str) – Name of the new load case.

  • formula (str) – Formula of the derived load case. Must follow the syntax detailed in the user’s manual.

Examples

>>> n2v.create_derived_lc('MyDerivedLC', '<LC1:FR1>+<LC2:FR1>')
n2vscripting.derived.create_envelope(name: str, list_lcs_incr: list[tuple[int, int]], criterion: str = 'Max', all_incr: bool = False) None#

Create an envelope load case in the current view.

Parameters:
  • name (str) – Name of the created envelope load case.

  • list_lcs_incr (list[tuple(int, int)]) – A list of load case ids to include in the envelope.

  • criterion (str, optional) – Criterion to use for calculating the envelope. Options available are: ‘Max’, ‘Min’, ‘ExtremeMax’, ‘ExtremeMin’ and ‘Range’. Default is ‘Max’.

  • all_incr (bool, optional) – Include all increments from the selected load cases in the envelope. Default: False.

Examples

>>> # Create an envelope lc from load cases 1, 2 and 3 using the Max criterion
>>> n2v.create_envelope('Envelope_max', [(1, 1), (2, 1), (3, 1)], 'Max')

Free Bodies commands#

NaxToView functions to create free body diagrams in the active view.

n2vscripting.freebodies.adjust_free_bodies_format(fx_show: bool = True, fx_color: str = '#FFFF0000', fx_scale: float = 1.0, fx_show_lc_label: bool = False, fx_show_value_label: bool = True, fy_show: bool = True, fy_color: str = '#FF00FF00', fy_scale: float = 1.0, fy_show_lc_label: bool = False, fy_show_value_label: bool = True, fz_show: bool = True, fz_color: str = '#FF0000FF', fz_scale: float = 1.0, fz_show_lc_label: bool = False, fz_show_value_label: bool = True, mx_show: bool = False, mx_color: str = '#FF00FFFF', mx_scale: float = 1.0, mx_show_lc_label: bool = False, mx_show_value_label: bool = True, my_show: bool = False, my_color: str = '#FFFF00FF', my_scale: float = 1.0, my_show_lc_label: bool = False, my_show_value_label: bool = True, mz_show: bool = False, mz_color: str = '#FFFFFF00', mz_scale: float = 1.0, mz_show_lc_label: bool = False, mz_show_value_label: bool = True, ftotal_show: bool = False, ftotal_color: str = '#FFFFFFFF', ftotal_scale: float = 1.0, ftotal_show_lc_label: bool = False, ftotal_show_value_label: bool = True, mtotal_show: bool = False, mtotal_color: str = '#FF000000', mtotal_scale: float = 1.0, mtotal_show_lc_label: bool = False, mtotal_show_value_label: bool = True, uniform_size: bool = False, global_scale: float = 0.3, labels_color: str = '#FFFFFF00') None#

Set visualization options for free body diagrams.

Calling this function sets all parameters that are not specified by the user to their default values.

Parameters:
  • fx_show (bool, optional) – Show X component of the free body forces. Default: True.

  • fx_color (str, optional) – Hex color code for the X component of the free body forces. Default: #FFFD0505 (Red)

  • fx_scale (float, optional) – Scale of the X component of the free body forces. Default: 1.0

  • fx_show_lc_label (bool, optional) – Show LC label on the X component of the free body forces. Default: False

  • fx_show_value_label (bool, optional) – Show value label on the X component of the free body forces. Default: True

  • fy_show (bool, optional) – Show Y component of the free body forces. Default: True.

  • fy_color (str, optional) – Hex color code for the Y component of the free body forces. Default: #FF00FF00 (Lime)

  • fy_scale (float, optional) – Scale of the Y component of the free body forces. Default: 1.0

  • fy_show_lc_label (bool, optional) – Show LC label on the Y component of the free body forces. Default: False

  • fy_show_value_label (bool, optional) – Show value label on the Y component of the free body forces. Default: True

  • fz_show (bool, optional) – Show Z component of the free body forces. Default: True.

  • fz_color (str, optional) – Hex color code for the Z component of the free body forces. Default: #FF0000FF (Blue)

  • fz_scale (float, optional) – Scale of the Z component of the free body forces. Default: 1.0

  • fz_show_lc_label (bool, optional) – Show LC label on the Z component of the free body forces. Default: False

  • fz_show_value_label (bool, optional) – Show value label on the Z component of the free body forces. Default: True

  • mx_show (bool, optional) – Show X component of the free body moments. Default: True.

  • mx_color (str, optional) – Hex color code for the X component of the free body moments. Default: #FF00FFFF (Aqua)

  • mx_scale (float, optional) – Scale of the X component of the free body moments. Default: 1.0

  • mx_show_lc_label (bool, optional) – Show LC label on the X component of the free body moments. Default: False

  • mx_show_value_label (bool, optional) – Show value label on the X component of the free body moments. Default: True

  • my_show (bool, optional) – Show Y component of the free body moments. Default: True.

  • my_color (str, optional) – Hex color code for the Y component of the free body moments. Default: #FFFF00FF (Fuchsia)

  • my_scale (float, optional) – Scale of the Y component of the free body moments. Default: 1.0

  • my_show_lc_label (bool, optional) – Show LC label on the Y component of the free body moments. Default: False

  • my_show_value_label (bool, optional) – Show value label on the Y component of the free body moments. Default: True

  • mz_show (bool, optional) – Show Z component of the free body moments. Default: True.

  • mz_color (str, optional) – Hex color code for the Z component of the free body moments. Default: #FFFFFF00 (Yellow)

  • mz_scale (float, optional) – Scale of the Z component of the free body moments. Default: 1.0

  • mz_show_lc_label (bool, optional) – Show LC label on the Z component of the free body moments. Default: False

  • mz_show_value_label (bool, optional) – Show value label on the Z component of the free body moments. Default: True

  • ftotal_show (bool, optional) – Show total free body force. Default: True.

  • ftotal_color (str, optional) – Hex color code for the total free body forces. Default: #FFFFFFFF (White)

  • ftotal_scale (float, optional) – Scale of the total free body forces. Default: 1.0

  • ftotal_show_lc_label (bool, optional) – Show LC label on the total free body forces. Default: False

  • ftotal_show_value_label (bool, optional) – Show value label on the total free body forces. Default: True

  • mtotal_show (bool, optional) – Show total free body moment. Default: True.

  • mtotal_color (str, optional) – Hex color code for the total free body moments. Default: #FF000000 (Black)

  • mtotal_scale (float, optional) – Scale of the total free body moments. Default: 1.0

  • mtotal_show_lc_label (bool, optional) – Show LC label on the total free body moments. Default: False

  • mtotal_show_value_label (bool, optional) – Show value label on the total free body moments. Default: True

  • uniform_size (bool, optional) – Set an uniform size for all plotted forces and moments. Default: False

  • global_scale (float, optional) – Scale factor applied if uniform_size is True. Default: 0.3

  • labels_color (str, optional) – Hex color code for value and lc labels. Default: #FFFFFF00 (Yellow)

n2vscripting.freebodies.calculate_free_bodies(section_names: List[str], lcs_incr: List[Tuple[int, int]]) None#

Run free body calculations for selected sections and load cases.

Parameters:
  • section_names (List[str]) – A list with the names of the selected sections.

  • lcs_incr (List[Tuple[int, int]]) – A list of tuples with the selected load case-increment pairs.

Examples

>>> n2v.calculate_free_bodies(['section1'], [(1, 0), (2, 0)])
>>> n2v.calculate_free_bodies(['section1', 'section2'], [(1, 0), (2, 0)])
n2vscripting.freebodies.create_new_section(section_name: str, nodes: list[int], elements: list[int], system: int = None, point: str = None) None#

Create a new free bodies section.

Parameters:
  • section_name (str) – Name of the new section.

  • nodes (list[int]) – List of node ids to include in the section.

  • elements (list[int]) – List of element ids to include in the section.

  • system (int, optional) – Id of the coordinate system to use. Default is 0 (global system).

  • point (str, optional) – A tuple with the x,y,z coordinates of the point at which to calculate the free bodies. If not provided, the centroid of the section is used.

Examples

>>> # Create a new section with some nodes and elements, using the global coordinate system and the centroid as calculation point
>>> n2v.create_new_section('Section1', [10000000, 10000001, 10000002], [20000000, 20000001, 20000002])
n2vscripting.freebodies.delete_section(section_name: str) None#

Delete a free body section.

Parameters:

section_name (str) – Name of the section to delete.

Examples

>>> n2v.delete_section('Section1')
n2vscripting.freebodies.export_free_bodies_to_excel(file_name: str, show_forces: bool = True, show_moments: bool = True, show_node_coords: bool = True, show_sys_coords: bool = True) None#

Export free body calculations to an Excel file.

Parameters:
  • file_name (str) – Path to the file in which to save the free body calculations.

  • show_forces (bool, optional) – Whether to show forces in the free body diagram.

  • show_moments (bool, optional) – Whether to show moments in the free body diagram. Default is True.

  • show_node_coords (bool, optional) – Whether to show node coordinates in the free body diagram. Default is True.

  • show_sys_coords (bool, optional) – Whether to show system coordinates in the free body diagram. Default is True.

Examples

>>> n2v.export_free_bodies_to_excel('C:/Path/To/FreeBodies.xlsx', True, True, True, True)
n2vscripting.freebodies.hide_free_body(section_name: str, lc: int, incr: int) None#

Hide free body diagram of a section, load case and increment.

Parameters:
  • section_name (str) – Name of the section.

  • lc (int) – Id of the load case.

  • incr (int) – Id of the increment.

Examples

>>> n2v.hide_free_body('Section1', 1, 0)
n2vscripting.freebodies.hide_section(section_name: str) None#

Hide section on the current view.

Parameters:

section_name (str) – Name of the section.

Examples

>>> n2v.hide_section('Section1')
n2vscripting.freebodies.show_free_body(section_name: str, lc: int, incr: int) None#

Show free body diagram of a section, load case and increment.

Parameters:
  • section_name (str) – Name of the section.

  • lc (int) – Id of the load case.

  • incr (int) – Id of the increment.

Examples

>>> n2v.show_free_body('Section1', 1, 0)
n2vscripting.freebodies.show_section(section_name: str) None#

Show section on the current view.

Parameters:

section_name (str) – Name of the section.

Examples

>>> n2v.show_section('Section1')

Plotting commands#

NaxToView functions to plot results in the active view.

n2vscripting.plot.clear_plot()#

Clear the plot in the currently active view.

n2vscripting.plot.plot_contour(lc: int, incr: int, result: str, component: str, sections: str, domain: Literal['Displayed', 'Selected', 'All'] = 'Displayed', avg_sec: Literal['Maximum', 'Minimum', 'Difference', 'Average', 'Extreme'] = 'Maximum', avg_pos: Literal['None', 'Maximum', 'Minimum', 'Difference', 'Average', 'Extreme'] = 'Maximum', corner_data: bool = False, cmplx_format: Literal['Real', 'Cartesian', 'Polar'] = 'Real', variation: int = 100) None#

Plot contour in the currently active view.

Parameters:
  • lc (int) – Id of the desired load case.

  • incr (int) – Number of the requested increment.

  • result (str) – Name of the requested result.

  • component (str) – Name of the requested component.

  • sections (str) – A string specifying the requested sections.

  • domain (str, optional) – Element/node domain which results are to be plotted on. Default is ‘Displayed’. Other options are ‘Selected’ and ‘All’.

  • avg_sec (str, optional) – Averaging criterion for sections. Default is ‘Maximum’. Other options are ‘Minimum’, ‘Difference’, ‘Average’ and ‘Extreme’.

  • avg_pos (str, optional) – Averaging criterion for positions. Default is ‘Maximum’. Other options are ‘Minimum’, ‘Difference’, ‘Average’ and ‘Extreme’.

  • corner_data (bool, optional) – Whether to express the results at nodal positions. Default is False.

  • cmplx_format (str, optional) – Format for complex results. Options are: ‘Real’, ‘Cartesian’ and ‘Polar’. Default is ‘Real’.

  • variation (int, optional) – % variation for nodal results averaging. Default is 100.

Examples

>>> # Plot the Von Mises stress in the first load case and increment, for Z1 and Z2 sections
>>> n2v.plot_contour(1, 1, 'STRESSES', 'VON_MISES', 'Z1#Z2#')
>>> # Plot X component of displacements in the first load case and increment, only in selected nodes
>>> n2v.plot_contour(1, 1, 'DISPLACEMENTS', 'X', 'NONE#', domain='Selected')
n2vscripting.plot.plot_tensors(lc: int, incr: int, result: str, sections: str, domain: Literal['Displayed', 'Selected', 'All'] = 'Displayed', coord_sys_id: int = 0, cmp_xx_displayed: bool = True, cmp_yy_displayed: bool = True, cmp_zz_displayed: bool = True, cmp_xy_displayed: bool = True, cmp_yz_displayed: bool = True, cmp_zx_displayed: bool = True, set_min_value: bool = False, min_value: float = 0.0, set_max_value: bool = False, max_value: float = 0.0, arrow_resolution: int = 2, scaling_used: Literal['Auto', 'ByValue', 'Uniform'] = 'Auto', scale_factor: float = 1.0, color_by_val: bool = True, xx_color_hex: str = '#FFFF0000', yy_color_hex: str = '#FF00FF00', zz_color_hex: str = '#FF0000FF', xy_color_hex: str = '#FFFFFF00', yz_color_hex: str = '#FF00B0F0', zx_color_hex: str = '#FFF324D9', show_labels_normals: bool = False, show_labels_shears: bool = False) None#

Plot tensors on the currently active view.

Parameters:
  • lc (int, optional) – Id of the requested load case.

  • incr (int, optional) – Id of the requested increment.

  • result (str, optional) – Name of the requested result.

  • sections (str, optional) – A string specifying the requested sections.

  • domain (str, optional) – A string specifying the domain in which to plot the vectors. Default is “Displayed”. Other options are: “Selected” and “All”.

  • coord_sys_id (int, optional) – Id of the coordinate system in which to express results.

  • cmp_xx_displayed (bool, optional) – Whether to show XX component of the requested result. Default is True.

  • cmp_yy_displayed (bool, optional) – Whether to show YY component of the requested result. Default is True.

  • cmp_zz_displayed (bool, optional) – Whether to show ZZ component of the requested result. Default is True.

  • cmp_xy_displayed (bool, optional) – Whether to show XY component of the requested result. Default is True.

  • cmp_yz_displayed (bool, optional) – Whether to show YZ component of the requested result. Default is True.

  • cmp_zx_displayed (bool, optional) – Whether to show ZX component of the requested result. Default is True.

  • set_min_value (bool, optional) – Whether to set a minimum threshold for plotted results. Default is False.

  • min_value (float, optional) – Minimum threshold for plotted results. Default is 0.

  • set_max_value (bool, optional) – Whether to set a maximum threshold for plotted results. Default is False.

  • max_value (float, optional) – Maximum threshold for plotted results. Default is 0.

  • arrow_resolution (int, optional) – Number of polygons used to draw the arrow tip. Default: 2.

  • scaling_used (bool, optional) – Whether to scale results by a factor. Default is False.

  • scale_factor (float, optional) – Scale factor for results. Default is 1.0.

  • color_by_val (bool, optional) – Whether to color tensor arrows by value. Default is True.

  • xx_color_hex (str, optional) – Hex color code for XX component of tensor if not colored by value. Default is “#FFFF0000”.

  • yy_color_hex (str, optional) – Hex color code for YY component of tensor if not colored by value. Default is “#FF00FF00”.

  • zz_color_hex (str, optional) – Hex color code for ZZ component of tensor if not colored by value. Default is “#FF0000FF”.

  • xy_color_hex (str, optional) – Hex color code for XY component of tensor if not colored by value. Default is “#FFFFFF00”.

  • yz_color_hex (str, optional) – Hex color code for YZ component of tensor if not colored by value. Default is “#FF00B0F0”.

  • zx_color_hex (str, optional) – Hex color code for ZX component of tensor if not colored by value. Default is “#FFF324D9”.

  • show_labels_normals (bool, optional) – Whether to show labels for normal components. Default is False.

  • show_labels_shears (bool, optional) – Whether to show labels for shear components. Default is False.

Examples

>>> # Plot stress tensor results
>>> n2v.plot_tensors(1, 1, 'STRESSES', 'Z1#Z2#')
>>> # Plot stress tensor results, showing XX and YY components only and only for selected elements
>>> n2v.plot_tensors(1, 1, 'STRESSES', 'Z1#Z2#', domain='Selected', cmp_zz_displayed=False, cmp_yz_displayed=False, cmp_zx_displayed=False)
n2vscripting.plot.plot_vectors(lc: int, incr: int, result: str, sections: str, domain: Literal['Displayed', 'Selected', 'All'] = 'Displayed', coord_sys_id: int = 0, is_rotation: bool = False, cmp_x_displayed: bool = True, cmp_y_displayed: bool = True, cmp_z_displayed: bool = True, resultant_displayed: bool = True, resultant_use_cmpx: bool = True, resultant_use_cmpy: bool = True, resultant_use_cmpz: bool = True, set_min_value: bool = False, min_value: float = 0, set_max_value: bool = False, max_value: float = 0, arrow_resolution: int = 2, scaling_used: Literal['Auto', 'ByValue', 'Uniform'] = 'Auto', scale_factor: float = 1, arrow_origin: Literal['Tail', 'Center', 'Tip'] = 'Tail', arrow_tip: Literal['Arrow', 'None'] = 'Arrow', color_by_val: bool = True, x_color_hex: str = '#FFFF0000', y_color_hex: str = '#FF00FF00', z_color_hex: str = '#FF0000FF', r_color_hex: str = '#FFE1E1E1', show_label_text: bool = False) None#

Plot vectors on the currently active view.

Parameters:
  • lc (int) – Id of the requested load case.

  • incr (int) – Id of the requested increment.

  • result (str) – Name of the requested result.

  • sections (str) – A string specifying the requested sections.

  • domain (str, optional) – A string specifying the domain in which to plot the vectors. Default is “Displayed”. Other options are: “Selected” and “All”.

  • coord_sys_id (int, optional) – Id of the coordinate system in which to express results

  • is_rotation (bool, optional) – If true, the vector is to be rotated. Default: False

  • cmp_x_displayed (bool, optional) – Whether to show X component of the requested result. Default: True

  • cmp_y_displayed (bool, optional) – Whether to show Y component of the requested result. Default: True

  • cmp_z_displayed (bool, optional) – Whether to show Z component of the requested result. Default: True

  • resultant_displayed (bool, optional) – Whether to show resultant of the requested result. Default: True

  • resultant_use_cmpx (bool, optional) – Whether to use X component of the requested result for the resultant. Default: True

  • resultant_use_cmpy (bool, optional) – Whether to use Y component of the requested result for the resultant. Default: True

  • resultant_use_cmpz (bool, optional) – Whether to use Z component of the requested result for the resultant. Default: True

  • set_min_value (bool, optional) – Whether to set a minimum threshold for plotted results. Default: False

  • min_value (float, optional) – Minimum threshold for plotted results. Default: 0

  • set_max_value (bool, optional) – Whether to set a maximum threshold for plotted results. Default: False

  • max_value (float, optional) – Maximum threshold for plotted results. Default: 0

  • arrow_resolution (int, optional) – Number of polygons used to draw the arrow tip. Default: 2.

  • scaling_used (bool, optional) – Whether to scale results by a factor. Default: False

  • scale_factor (float, optional) – Scale factor for results. Default: 1.0

  • arrow_origin (str, optional) – Origin of the arrow. Default: “Tail”

  • arrow_tip (str, optional) – Type of arrow tip. Default: “Arrow”

  • color_by_val (bool, optional) – Whether to color vector arrows by value. Default: True

  • x_color_hex (str, optional) – Hex color code for X component of vector if not colored by value. Default: “#FFFF0000”

  • y_color_hex (str, optional) – Hex color code for Y component of vector if not colored by value. Default: “#FF00FF00”

  • z_color_hex (str, optional) – Hex color code for Z component of vector if not colored by value. Default: “#FF0000FF”

  • r_color_hex (str, optional) – Hex color code for resultant of vector if not colored by value. Default: “#FFE1E1E1”

  • show_label_text (bool, optional) – Whether to show label text. Default: False

Examples

>>> # Plot displacement vectors
>>> n2v.plot_vectors(1, 1, 'DISPLACEMENTS', 'NONE#')
>>> # Plot forces vectors, showing X and Y components only and only for selected elements
>>> n2v.plot_vectors(1, 1, 'FORCES', 'NONE#', domain='Selected', cmp_z_displayed=False, resultant_use_cmpz=False)
n2vscripting.plot.set_deformed_scale(value: float = 1.0) None#

Set the scale of the deformed shape on the active view.

Parameters:

value (float, optional) – Scale multiplier. Default is 1.0.

Examples

>>> n2v.set_deformed_scale(2.0)
n2vscripting.plot.set_deformed_style(repr_type: Literal[0, 1, 2, 3, 4] = 0, color: str = '#FFFDFDFD') None#

Set the style of the deformed shape on the active view.

Parameters:
  • repr_type (int, optional) – Mesh representation type. Default is 0.

  • color (str, optional) – Hex color code for the mesh representation. Default: #FFFDFDFD.

Examples

>>> # Set deformed style to opaque wireframe, with color set to a dim gray (#FF6B6B7C)
>>> n2v.set_deformed_style(1, '#FF6B6B7C')
n2vscripting.plot.toggle_deformed() None#

Activate/deactivate deformed view.

n2vscripting.plot.toggle_undeformed() None#

Activate/deactivate the undeformed shaped view on the active view.

Report commands#

NaxToView functions to create reports from the active view.

n2vscripting.report.create_report(path: str, items: list[int], item_type: str, lcs_incr: list[tuple[int, int]], result: str, components: list[str], sections: str, all_incr: bool = False, sort_by: str = 'LC', avg_sec: str = 'Maximum', avg_pos: str = 'Maximum', variation: int = 100, coord_sys_id: int = -1, complex_format: str = 'Real', corner_data: bool = False, env_only: bool = False)#

Create a Report on the active view and save it to a file.

More detailed description of the function and how to use it and bla bla bla.

Parameters:
  • path (str) – Path of the file the report is to be saved to.

  • items (list[int]) – List of element or node ids.

  • item_type (str) – ‘Elements’ or ‘Nodes’

  • lcs_incr (list[tuple[int, int]]) – list of tuples of load case ids and increments to include in the report.

  • result (str) – name of the result

  • components (list[str]) – list of names of components to include in the report.

  • all_incr (bool, optional) – Whether to include all increments or just the ones specified in lcs_incr. Default is False.

  • sections (str) – A string with the sections to include in the report. The sections are separated by #. Whether to include all increments or just the ones specified in lcs_incr.

  • sort_by (str, optional) – ‘LC’ or ‘Item’. If ‘LC’, the report will be sorted by load case. If ‘Item’, the report will be sorted by item.

  • avg_sec (str, optional) – A string that specifies the criterion to be used for section averaging.

  • avg_pos (str, optional) – A string that specifies the criterion to be used for position averaging.

  • variation (int, optional) – An integer that specifies the variation to be used for the report. Default is 100.

  • coord_sys_id (int, optional) – An integer that specifies the coordinate system to be used for the report. Default is -1.

  • complex_format (str, optional) – A string that specifies the complex format to be used for the report. Options are: ‘Real’, ‘Cartesian’ and ‘Polar’. Default is ‘Real’.

  • corner_data (bool, optional) – A boolean that specifies whether to express the results at nodal positions. Default is False.

  • env_only (bool, optional) – A boolean that specifies whether to include only the envelope results. Default is False.

Examples

>>> n2v.create_report("C:/Path/To/Report.csv", [100000, 100001, 100002], "Elements", [(1, 0), (2, 0)], "STRESSES", ["XX", "YY", "ZZ"], "Z1#Z2#")

Scalarbar commands#

NaxToView functions to set the legend parameters for a visualization scene.

n2vscripting.scalarbar.set_legend(legend_type: str, position: Literal['Right', 'Left', 'Middle'] = 'Right', num_colors: int = 12, labels_color: str = '#FF0A0707', background_border: bool = False, legend_colors: tuple[str] = ('#FF0000FF', '#FF0049FF', '#FF00D2FF', '#FF00FFF9', '#FF00FF92', '#FF00FF14', '#FF14FF00', '#FF91FF00', '#FFF9FF00', '#FFFFD300', '#FFFF4A00', '#FFFF0000'), labels_font: Literal['Arial', 'Courier', 'Times'] = 'Arial', labels_bold: bool = False, labels_size: int = 12, labels_num_digits: int = 4, labels_num_format: Literal['Scientific', 'Fixed'] = 'Fixed', set_min_range: bool = False, min_range_value: float = 0.0, set_max_range: bool = False, max_range_value: float = 0.0, reverse_legend: bool = False, upper_text_font: Literal['Arial', 'Courier', 'Times'] = 'Arial', upper_text_size: int = 12, upper_text_bold: bool = False, lower_text_font: Literal['Arial', 'Courier', 'Times'] = 'Arial', lower_text_size: int = 12, lower_text_bold: bool = False)#

Configure and set the legend parameters for a visualization scene.

Parameters:
  • legend_type (str) – The type of legend to set. Options are ‘Scalar’, ‘Vector’, or ‘Tensor’.

  • position (str, optional) – The position of the legend in the scene. Default is ‘Right’. Other options are ‘Left’ and ‘Middle’.

  • num_colors (int, optional) – The number of colors to display in the legend. Default is 12.

  • labels_color (str, optional) – The color of the labels in hexadecimal format. Default is “#FF0A0707”.

  • background_border (bool, optional) – Whether to display a border around the legend background. Default is False.

  • legend_colors (tuple[str], optional) – A tuple of hexadecimal color codes for the legend.

  • labels_font (str, optional) – The font used for the legend labels. Default is ‘Arial’.

  • labels_bold (bool, optional) – Whether the legend labels should be bold. Default is False.

  • labels_size (int, optional) – The font size of the legend labels. Default is 12.

  • labels_num_digits (int, optional) – The number of digits to display for numeric labels. Default is 4.

  • labels_num_format (str, optional) – The numeric format for labels (‘Fixed’ or ‘Scientific’). Default is ‘Fixed’.

  • set_min_range (bool, optional) – Whether to set a minimum range for the legend. Default is False.

  • min_range_value (float, optional) – The minimum range value for the legend. Default is 0.0.

  • set_max_range (bool, optional) – Whether to set a maximum range for the legend. Default is False.

  • max_range_value (float, optional) – The maximum range value for the legend. Default is 0.0.

  • reverse_legend (bool, optional) – Whether to reverse the order of the legend colors. Default is False.

  • upper_text_font (str, optional) – The font used for the upper text in the legend. Default is ‘Arial’.

  • upper_text_size (int, optional) – The font size of the upper text in the legend. Default is 12.

  • upper_text_bold (bool, optional) – Whether the upper text in the legend should be bold. Default is False.

  • lower_text_font (str, optional) – The font used for the lower text in the legend. Default is ‘Arial’.

  • lower_text_size (int, optional) – The font size of the lower text in the legend. Default is 12.

  • lower_text_bold (bool, optional) – Whether the lower text in the legend should be bold. Default is False.

Selection commands#

NaxToView functions to control the selection in the active view.

n2vscripting.selection.clear_selection() None#

Clear current selection.

n2vscripting.selection.create_group(group_name: str) None#

Create a group with the currently selected elements.

n2vscripting.selection.get_all_elements_list()#

Get a list of all elements in the model.

n2vscripting.selection.get_list_selected_items() list[int]#

Get a list with the ids of the current selection.

Return type:

A list of ints with the ids of the currently selected items.

Examples

>>> selected_items = n2v.get_list_selected_items()
n2vscripting.selection.get_visible_elements_list()#

Get a list with the ids of all visible elements.

n2vscripting.selection.hide_free_edges() None#

Hide free edges in the model.

n2vscripting.selection.hide_selected() None#

Hide current selection. Only valid for element selection.

n2vscripting.selection.isolate_group(group_name: str) None#

Isolate elements from a group.

Parameters:

group_name (str) – Name of the desired group.

Examples

>>> n2v.isolate_group('MyGroup')
n2vscripting.selection.isolate_selected() None#

Isolate current selection. Only valid for element selection.

n2vscripting.selection.reverse_selection() None#

Reverse current selection.

n2vscripting.selection.reverse_visible() None#

Reverse visibility of the whole model.

n2vscripting.selection.select_adjacent() None#

Add adjacent elements to current selection. Only valid for element selection.

n2vscripting.selection.select_all_elements()#

Select all elements in the active view.

n2vscripting.selection.select_attached() None#

Add attached elements to current selection. Only valid for element selection.

n2vscripting.selection.select_by_face() None#

Add all elements in the same face(s) as current selection to it. Only valid for element selection.

n2vscripting.selection.select_elements(elements_list: list[int], part_id: int = 0) None#

Select elements from the current view given a list of ids.

Parameters:
  • elements_list (list[int]) – The list of elements to be selected.

  • part_id (int, optional) – ID of the part. Default is 0.

Examples

>>> n2v.select_elements([10000000, 10000001, 10000002])
>>> n2v.select_elements([10000000])
n2vscripting.selection.select_group_elements(group_name: str) None#

Add elements from a group to current selection.

Parameters:

group_name (str) – Name of the desired group.

Examples

>>> n2v.select_group_elements('MyGroup')
n2vscripting.selection.select_nodes(nodes_list: list[int]) None#

Select nodes from the current view given a list of ids.

Parameters:

nodes_list (list[int]) – The list of nodes to be selected.

Examples

>>> n2v.select_nodes([10000000, 10000001, 10000002])
>>> n2v.select_nodes([10000000])
n2vscripting.selection.select_visible_elements()#

Select all currently visible elements.

n2vscripting.selection.show_all() None#

Show the whole model.

n2vscripting.selection.show_free_edges() None#

Show free edges in the model.

n2vscripting.selection.show_selected() None#

Show current selection. Only valid for element selection.

n2vscripting.selection.toggle_item_labels() None#

Toggle id labels on the current selection.

n2vscripting.selection.unhide_adjacent() None#

Show elements adjacent to current selection. Only valid for element selection.

Tags commands#

NaxToView functions to create tags in the active view.

n2vscripting.tags.create_tag(name: str, list_items: list[int], type_items: str, text_color: str = '#FF151412', fill_color: str = '#FFFFF768', tag_text: str = 'Id: ={ID::ENTITY}\r\nContour: ={CONTOUR::ENTITY,%.2f}\r\n', always_displayed: bool = True, info_tooltip: bool = False, fixed: bool = False, text_align: Literal['Down - Left', 'Down - Centered', 'Down - Right', 'Top - Left', 'Top - Centered', 'Top - Right', 'Middle - Left', 'Middle - Centered', 'Middle - Right'] = 'Down - Left', border: bool = True, font: dict[str, any] = {'Name': 'Arial', 'Size': 14, 'Style': 'Normal', 'Weight': 'Bold'}, target: dict[str, any] = {'Criterion': 'MAX', 'Field': 'CONTOUR', 'Value': ''}) None#

Create a tag in the active view.

Parameters:
  • name (str) – Name of the tag. Must be unique.

  • list_items (list[int]) – List of items that make the domain of the tag.

  • type_items (str) – Type of the items. “Elements” or “Nodes”.

  • text_color (str, optional) – Color of the text.

  • fill_color (str, optional) – Color of the background of the tag.

  • tag_text (str, optional) – Text to be displayed on the tag.

  • always_displayed (bool, optional) – If true, the tag will always be displayed on top of the model.

  • info_tooltip (bool, optional) – If true, the tag will be used as template for the info tooltip.

  • fixed (bool, optional) – If true, the tag will be fixed to a point in the screen when the model is moved or rotated.

  • text_align (str, optional) – Alignment of the text inside the tag. Options are:

  • border (bool, optional) – If true, the tag will have a black border.

  • font (dict[str, any], optional) –

    A dictionary of font options:
    • ’Name’: name of the font. Must be available on your system.

    • ’Style’: “Normal” or “Italic”.

    • ’Weight’: “Normal” or “Bold”.

    • ’Size’: an integer specifying font size.

  • target (dict[str, any], optional) –

    A dictionary of target options:
    • ’Field’: target field to apply criterion to. Usually, and by default, ‘CONTOUR’.

    • ’Criterion’: ‘MAX’, ‘MIN’, ‘EXTREME_MAX’, ‘EXTREME_MIN’, ‘EQUAL’, ‘GREATER’, ‘LESS’ or ‘RANGE’. Default is ‘MAX’.

Examples

>>> # To create a tag with the maximum contour value of elements 1, 2 and 3:
>>> n2v.create_tag('MyTag', [1, 2, 3], 'Elements')
>>> # To create a tag with the minimum contour value of nodes 1, 2 and 3, changing some format options:
>>> n2v.create_tag('MyTag2', [1, 2, 3], 'Nodes', text_color="#FF0000FF", font={'Name': 'Courier', 'Style': 'Normal', 'Weight': 'Bold', 'Size': 10}, target={'Field': 'CONTOUR', 'Criterion': 'MIN', 'Value': ''})
n2vscripting.tags.delete_tag(name)#

Delete a tag in the active view.

Parameters:

name (str) – Name of the tag to be deleted.

Examples

>>> n2v.delete_tag('MyTag')

View commands#

NaxToView functions to control the view in the active scene.

n2vscripting.view.autofit()#

Center scene in current view.

n2vscripting.view.set_mesh_view_mode(mode: Literal[0, 1, 2, 3, 4])#

Set the mesh representation type.

Parameters:

mode (int) –

Id of the visualization mode. Available options are:
  • 0: Opaque

  • 1: Opaque Wireframe

  • 2: Transparent

  • 3: Transparent Wireframe

  • 4: Opaque Feature Edges

Examples

>>> set_mesh_view_mode(0)   # Opaque
>>> set_mesh_view_mode(1)   # Opaque Wireframe
>>> set_mesh_view_mode(2)   # Transparent
n2vscripting.view.toggle_axes()#

Switch axes visibility from true to false or vice versa.