NaxToPy API Reference

Contents

NaxToPy API Reference#

Direct Functions#

class NaxToPy.N2PLog[source]#

Bases: ABC

Class prepared for the control of the program.

It uses the module logging to register the main instructions and data of the NaxToPy Package. It can’t be instanced.

LevelList#
class Critical[source]#

Bases: object

Class with all the critical errors.

The critical are methods that do not return anything, they write in the log file and console the error. Optionally a raise Exception could be added. Always a sys.exit() should be executed at the end.

static user(message: str) None[source]#

Method prepared to be called by the user for adding CRITICAL errors to the loggin.

Anyone who is using NaxToPy can write in the register their own CRITICAL error message. Use the following structure as a standard message (C + four digits + Body).

Parameters:

message – str

Example

“CXXXX: BODY OF THE MESSAGE”

class Debug[source]#

Bases: object

Class with all the debug data.

The DXXX are methods that keep in the register the information in the debuggibg procces about the processes that the package is keeping. Use only in the debug stages.

static user(message: str) None[source]#

Method prepared to be called by the user for adding debugs data to the loggin

Anyone who is using NaxToPy can write in the register their own debug message. Use the following structure as a standard message (D + four digits + Body).

Parameters:

message – str

Example

“DXXXX: Body of the message”

class Error[source]#

Bases: object

Class with all the errors that can be expected.

They should be handeled by a try-exception clasule. The errors are method that do not return anything, they write in the log file and console the error.

static user(message: str) None[source]#

Method prepared to be called by the user for adding errors to the loggin

This anyone who is using NaxToPy can write in the register their own error message. Use the following structure as a standard message (E + four digits + Body).

Parameters:

message – str

Example

“EXXXX: BODY OF THE MESSAGE”

class Info[source]#

Bases: object

Class with all the information data. The IXXX are methods that keep in the register the information about the processes that the package is keeping.

static user(message) None[source]#

Method prepared to be used by the user so anyone who is using NaxToPy can write in the register their own information message. Use the following structure as a standard message (I + four digits + Body).

“IXXXX: Body of the message”

class property LevelList: list[str]#

Property that retuns the list with the message levels in the log

class Warning[source]#

Bases: object

Class with all the warnings. The WXXX are methods that keep in the register the warnings that might be revised. They don’t affect directly to the correct working of the package.

static user(message) None[source]#

Method prepared to be used by the user so anyone who is using NaxToPy can write in the register their own warning message. Use the following structure as a standard message (W + four digits + Body).

“WXXXX: Body of the message”

classmethod activate_log() None[source]#

Method that activates the .log

classmethod deactivate_log() None[source]#

Method that deactivates the .log

classmethod get_directory() str[source]#

Method that returns the folder where the .log file is being saved

classmethod get_file_name() str[source]#

Method that returns the name of the file of the .log

classmethod set_console_level(clv: Literal['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']) None[source]#

Method to set a different level for console register. The default level is “WARNING”. Only The level register and higher will be printed in the console. The possible levels are:

“DEBUG”, “INFO”, “WARNING”, “ERROR”, “CRITICAL”.

classmethod set_directory(value: str) None[source]#

Method that sets the folder where the .log file must be saved

Parameters:

value – str -> Path to the folder where the .log must be saved.

classmethod set_file_level(flv: Literal['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']) None[source]#

Method to set a different level for the file .log of the register. The default level is “INFO”. Only The level register and higher will be printed in the .log file. Higher levels could make more difficult to track errors. The possible levels are:

“DEBUG”, “INFO”, “WARNING”, “ERROR”, “CRITICAL”.

classmethod set_file_name(value: str) None[source]#

Method that sets the name of the file of the .log

Parameters:

value – str -> Name of the .log file

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', 'InputFileAbaqus', 'Binary'] = None, dict_gen: dict = None, filter: Literal['ELEMENTS', 'PROPERTIES', 'PARTS', 'NODES'] = None) 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)

Args:

path: str 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”), 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_gem: 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:

model: N2PModelContent

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")
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\myscript1.py")
>>> n2ptoexe(r"C:\Scripts\myscript2.py", console=False, solver="NASTRAN")
>>> n2ptoexe(r"C:\Scripts\myscript3.py", console=True, solver="OPTISTRUCT", splash=r"C:\Scripts\mysplash.jpg")
>>> n2ptoexe(r"C:\Scripts\myscript4.py", extra_packages=["sv_ttk"], extra_files=[r"C:\Scripts\icon.png"])
>>> n2ptoexe(r"C:\Scripts\myscript5.py", hidden_imports=["plyer.platforms.win.notification"])

Folders#