N2PNastranInputData#

class NaxToPy.Core.Classes.N2PNastranInputData.N2PNastranInputData(dictcardscston2p: dict, inputfiledata)[source]#

Bases: object

Class with the complete data of a MEF input file (text file).

Note

The property N2PModelContent.ModelInputData can be a N2PNastranInputData if the input file is from Nastran (.bdf) or Opstitruct (.fem), or a N2PAbaqusInputData (.inp) if is from Abaqus.

Example

>>> model = n2p.load_model("my_nastran_input_file.bdf")
>>> inputdata = model.ModelInputData  # This is a N2PNastranInputData
create_card(card_type: str, bdf_file: str, rawContent: str = None, superElemntId: int = 0) N2PCard[source]#

Method that creates a new card of the type specified. By default, the card is created empty, with small field format.

Example

>>> new_cbar = model.ModelInputData.create_card("CBAR", "C:\bdf\mesh\model.bdf")
>>> # new_cbar is now a N2PCard object of type CBAR empty. You can set its properties:
>>> new_cbar.EID = 1001
>>> new_cbar.PID = 2001
>>> new_cbar.GA = 10
>>> new_cbar.GB = 20
>>> new_cbar.X1 = 1.0
>>> new_cbar.X2 = 0.0
>>> new_cbar.X3 = 0.0
>>> # It is also possible to create a card with raw content and specifying the superelement id:
>>> raw_content = "CBAR        1002    2001      30      40     0.0     1.0     0.0"
>>> new_cbar2 = model.ModelInputData.create_card("CBAR", "C:\bdf\mesh\model.bdf", rawContent=raw_content, superElemntId=0)
find_cards(category: Literal['GRID', 'ELEMENT', 'CONNECTOR', 'PROPERTY', 'MATERIAL', 'COORDINATESYSTEM', 'LOAD', 'CONSTRAINT'], cardTypes: list[str] = None, filters: dict[str, object] = None, superElements: int = None) list[N2PCard][source]#

Searches for cards based on specified criteria.

Parameters:
  • category – Card category to search. Valid values: GRID, ELEMENT, CONNECTOR, PROPERTY, MATERIAL, COORDINATESYSTEM, LOAD, CONSTRAINT.

  • cardTypes – Specific card types to filter by (e.g., CQUAD4, PBEAM, COORD2R). If None, all card types within the category are returned.

  • filters – Dictionary of field-value pairs to filter results. Available fields depend on the category: - GRID: “ID”, “CP”, “CD”, “PS”, “SEID”, “X1”, “X2”, “X3” - ELEMENT: “EID”, “PID”, “NodeArray” - CONNECTOR: - PROPERTY: “PID” - MATERIAL: “MID” - COORDINATESYSTEM: “CoordinateSystemIds”, “ReferenceSystemId” - LOAD: - CONSTRAINT:

  • superElements – Superelement (part) ID to search within. Use 0 for the global model. If None, searches across all superelements.

Returns:

List of N2PCard objects matching the specified criteria.

Examples

>>> # Get all grids from global model
>>> grids = model.ModelInputData.find_cards("GRID", superElements=0)
>>> # Get all CQUAD4 elements from global model
>>> quads = model.ModelInputData.find_cards("ELEMENT", ["CQUAD4"], superElements=0)
>>> # Get PSHELL property with PID=3
>>> pshell_3 = model.ModelInputData.find_cards("PROPERTY", ["PSHELL"], {"PID": 3}, superElements=0)
>>> # Get all grids with CP=10 across all superelements
>>> grids_cp10 = model.ModelInputData.find_cards("GRID", filters={"CP": 10})
get_cards_by_field(fields: list[str], row: int = 0, col: int = 0) list[N2PCard][source]#

ATTENTION: Deprecated method in version 3.2.0. Use find_cards() instead.

get_failed_cards() list[N2PCard][source]#

Method that returns a list with the N2PCard objects of the input FEM file that have not been mapped correctly.

print_include_hierarchy() None[source]#

Function that prints in the console the hierarchy of includes of a Nastran input file.

print_model_directory_structure() None[source]#

Function that prints in the console the directory structure of a Nastran input file.

rebuild_file(folder: str) None[source]#

Method that writes the solver input file with the same file structure that was read in the folder is specified

Parameters:

folder – str -> Path of the folder where the file or files will be written.

property CaseControlInstructions: list[N2PInputDataNas]#

Executive Control Statements and Control Case Commands

Type:

List with the instructions of the model. They are the commands above the BEGIN BULK

property ExecutiveControlInstructions: list[N2PInputDataNas]#

Executive Control Statements and Control Case Commands

Type:

List with the instructions of the model. They are the commands above the BEGIN BULK

property GetAbsolutePathsOfBdfFiles: list[str]#

List with theabsolute file paths of all BDF files that compose this model

property ListBulkDataCards: list[N2PCard]#

List with the N2PCard objects of the input FEM file. It has all bulk data cards of the model

property ListInstructions: list[N2PInputDataNas]#

Executive Control Statements and Control Case Commands

Type:

List with the instructions of the model. They are the commands above the BEGIN BULK

N2PInputDataNas#

class NaxToPy.Core.Classes.N2PNastranInputData.N2PInputDataNas(inputdata)[source]#

Bases: object

General class for the information in an input file of Nastran

last_status_message() None[source]#

Method that checks if the last operation on the model was successful. If not, it raises an error with the message of the last operation.

property BdfFile: str#
property BdfFilePath: str#
property RawContent: str#
property SectionInfo: object#