Hi @AKD-Scripting-Team
I have .op4 (Nastran) file, want to open in Ansys it could be in csv or .cdb formats If possible through scripts any suggestions would be helpful
Regards Naveen Kumar B
Hi @Naveen Kumar Begari ,
Please have a look at this:
https://pynastran-git.readthedocs.io/en/latest/quick_start/features.html#op4-reader-writer
or here: https://pyyeti.readthedocs.io/en/latest/tutorials/op4.html
Hi @Rajesh Meena & @M Thanks for your quick response.
With the help of those websites, I created this script yesterday:
` import numpy as np from pyyeti.nastran import op4 file_path = "nastran.op4" matrices = op4.read(file_path, justmatrix=True) print("Available Matrices:", matrices.keys())
matrix_name = list(matrices.keys())[0] matrix_data = matrices[matrix_name]
print(f"Matrix {matrix_name}:") print(matrix_data) matrix_data = matrices[matrix_name] if isinstance(matrix_data, tuple): matrix_data = matrix_data[0] # Extract only the numerical matrix matrix_data = np.atleast_2d(matrix_data) np.savetxt(f"{matrix_name}.csv", matrix_data, fmt="%.6f", delimiter=" ") `
but it doesn't work well as expected
Hi @Naveen Kumar Begari , this is not enough information for us to help. What is the expected behavior ? What is not working ? Do you have an error message ?
@Pernelle Marone-Hitz how can I read the .csv file or any other supported file for Ansys which was generated by Nastran .op4 file.
No error message it is getting.
@Naveen Kumar Begari What I meant if, from the code you shared, what is not working? Also tagging @Pierre Thieffry who might have done this in the past.
@Naveen Kumar Begari what do you want to do with the matrices from the op4 file?
@Pierre Thieffry
In Nastran, the .op4 file contains matrix data used in finite element analysis (FEA). The element matrix is used for several reasons:
Structural Stiffness – It represents the stiffness contribution of individual elements in the global system.
Mass and Damping – It stores mass and damping matrices for dynamic analysis.
Load Influence – Helps in calculating response due to applied loads.
Modal Analysis – Used to compute eigenvalues and eigenvectors for vibration analysis.