API Reference#

Direct Functions#

NaxToPy.OpenFiletoN2P(n2v_instance: N2ModelContent) N2PModelContent[source]#

Read a N2ModelContent object and transform it into a N2PModelContent object.

Parameters:

n2v_instance – N2ModelContent. Mandatory.

NaxToPy.envelope_list(*args: list) list[list][source]#

Function that generates the envelope of a cloud of points. Args could be DF or lists.

-args*: Lists as columns of the cloud of points: e = n2p.envelope([3,4,2,…], [6,2,7,…], …)

-arg: A single DataFrame: e = n2p.envelope(df)

Returns:

list[list]

Note

The column 0 is the solver element id when using DataFrame, but it is the position in the elements list when using lists!!! to know the solver id: get_elements()[index_0]

NaxToPy.envelope_ndarray(array2D: ndarray) ndarray[source]#

Function that generates the envelope of a cloud of points. Args must be a numpy.array. This function is faster than envelope_list.

Parameters:

array2D (ndarray) – 2D Array [n*m]. Each row is point of the cloud, so there are n points. Each column is a coordinate of the point, so it is an m dimensional space.

Returns:

ndarray

Note

The column 0 is the position in the elements list!!! to know the solver id: get_elements()[index_0]

NaxToPy.initialize(path: str, parallelprocessing: bool = False) N2PModelContent[source]#

Deprecated function. This funtion has been substituted by load_model()

NaxToPy.load_model(path: str, parallelprocessing: bool = True, file_type: Literal['InputFileNastran', 'InputFileOptistruct', 'InputFileAbaqus', 'Binary'] = None, dict_gen: dict = None, filter: Literal['ELEMENTS', 'PROPERTIES', 'PARTS', 'NODES'] = None, loadconnectors=True) N2PModelContent[source]#

Read an output result file in binary format from Nastran, Abaqus, Optistruct or Ansys and transform it into a N2PModelContent Object. It also can read models from input files in Nastran format.

Supports .op2, .xdb, .odb, .h5, .h3d and .rst file extensions read from a local filesystem or URL.

Supports Nastran Input Files (typically .bdf extension) and Abaqus Input File (typically .inp extension)

Parameters:
  • path – str. Mandatory.

  • parallelprocessing – bool. Optional. If true, the low libraries open the result files in several processes. It is slightly faster.

  • file_type – str. Optional. It specifies if it is Nastran input file (“InputFileNastran”), Optistruct input file (“InputFileOptistruct”), Abaqus input file (“InputFileAbaqus”) or binary result file (“Binary”).

  • filter – str. Optional. It specifies what to load in dict_gen (elements, properties, parts or nodes)

  • dict_gen – dict. Optional. Dictionary that represents what elements/properties/parts/nodes to load. For elements and nodes, the dictionary is in the form {Part ID (str): [Elements ID/Nodes ID]}. For parts or properties, the dictionary could simply be in the form {Part ID (str) / Property ID (str): []}.

Returns:

Instance with all the model data.

Return type:

N2PModelContent

Note

WHAT THE NASTRAN/OPTISTRUCT INPUT FILE READER TAKES DOWN IS NOT ASKED FOR HERE. It is derived from the register level of NaxToPy: the reader is asked for every severity that would still be seen either in the .log file or in the console, and for no other one. Whatever it takes down while reading reaches the NaxToPy register as soon as the model finishes loading, each message keeping the severity the reader gave it: an error as an error, a warning as a warning and a successful operation as information.

THE LEVEL HAS TO BE SET BEFORE THIS CALL, and that stays true even though a later change is carried to the models already open. The reader is built while the file is being opened and applies the policy it has at that instant, so a change made afterwards reaches the operations that come next and never the reading itself: what was not taken down while the file was read was never stored anywhere to be recovered from.

The derivation takes the LEAST RESTRICTIVE of the two levels, the .log file one and the console one, because one destination accepting a record is enough for it to be seen. Raising only one of the two can therefore leave the policy exactly where it was.

It applies neither to binary result files nor to Abaqus input files, which are read by a different component.

Examples

>>> model1 = load_model(r"C:\MODELS\FEM\model1.dat")
>>> # file_type is not needed. It only helps the program and saves a checking
>>> model2 = load_model(r"C:\MODELS\FEM\model2.dat", file_type="InputFileNastran")
>>> # parallelprocessing is only aviable for Binary files. It is helpful in some big files.
>>> model3 = load_model(r"C:\MODELS\RESULTS\model1.op2", parallelprocessing=True)
>>> model4 = load_model(r"C:\MODELS\RESULTS\model2.xdb", file_type="Binary")
>>> model5 = load_model(r"C:\MODELS\RESULTS\model5.h3d")
>>> model6 = load_model(r"C:\MODELS\RESULTS\model6.odb", True, "Binary")
>>> # The register level has to be set BEFORE loading: it is what decides how much the
>>> # Nastran/OptiStruct input file reader takes down while the file is being read.
>>> N2PLog.set_file_level("ERROR")
>>> N2PLog.set_console_level("ERROR")
>>> model7 = load_model(r"C:\MODELS\FEM\model7.bdf")
NaxToPy.n2ptoexe(path: str, console: bool = True, solver: Literal['ALL', 'NASTRAN', 'ABAQUS', 'ANSYS', 'OPTISTRUCT'] = 'ALL', abaqusversion: list[Literal['2016', '2017', '2018', '2019', '2020', '2021', '2022', '2023', '2024', '6.11', '6.12', '6.13', '6.14']] = None, splash: str = '', extra_packages: list[str] = None, extra_files: list[str] = None, hidden_imports: list[str] = None) None[source]#

Function that creates .exe files of programs that use NaxToPy

Parameters:
  • path – str -> path of the module that will be used to create the .exe file

  • console – bool -> If True (Default), the .exe will opne a console of python. If False, the .exe will not open any python console.

  • solver – srt | list[str] -> Default=”ALL” Solver or list of solvers that the module will work with. Posible solvers are: “NASTRAN”, “ABAQUS”, “ANSYS”, “OPTISTRUCT”

  • abaqusversion – str | list[srt] -> Default=’2022’. Only when “ABAQUS” is selected a str or a list of ABAQUS version are aviable. Posible abaqus versions: [‘2016’, ‘2017’, ‘2018’, ‘2019’, ‘2020’, ‘2021’, ‘2022’, ‘6.11’, ‘6.12’, ‘6.13’, ‘6.14’]

  • splash – str -> Optional. Path to the splash image. If used, the user must introduce pyi_splash.close() at the beginning of the execution of the module. Import pyi_splash first. The splash image will appear during the .exe unpacking. Image should be png and smaller than 500x500 pixels.

  • extra_packages – list[str] -> If some packages are not imported correctly by the function, they can be added manually. An example of a package that usually fails is ‘sv_ttk’.

  • extra_files – list[str] -> Lis of path of extra dll, images or other files the user want to add the exe. The files will be saved in the ./bin directory inside the exe. To acces to the files use: path_file = os.path.join(sys._MEIPASS, r”binmylib.dll”)

Examples

>>> n2ptoexe(r"C:\Scripts\script1.py")
>>> n2ptoexe(r"C:\Scripts\script2.py", console=False, solver="NASTRAN")
>>> n2ptoexe(r"C:\Scripts\script3.py", console=True, solver="OPTISTRUCT", splash=r"C:\Scripts\mysplash.jpg")
>>> n2ptoexe(r"C:\Scripts\script4.py", extra_packages=["sv_ttk"], extra_files=[r"C:\Scripts\icon.png"])
>>> n2ptoexe(r"C:\Scripts\script5.py", hidden_imports=["plyer.platforms.win.notification"])

Contents#