SteveDoyle2 / pyNastran

A Python-based interface tool for Nastran's file formats
Other
384 stars 147 forks source link

Can I convert an op2 file without a bdf file to a vtk file? #777

Closed guotao1415 closed 4 months ago

guotao1415 commented 5 months ago

I am Sorry to bother you again, you said "There is no bdf_2_vtk or op2_2_vtk function. I believe the function you’re after is nastran_to_vtk."

Do you mean that both bdf and op2 files need to be present in order to convert them into vtk files? Can I convert an op2 file without a bdf file to a vtk file?

The op2 file seems to contain geometric information. I tried the following example but encountered an error:

op2_filename = 'fem.op2'
vtk_filename = 'fem.vtu'
model = read_op2_geom(op2_filename)
nastran_to_vtk(model, model, vtk_filename)
Traceback (most recent call last):
File "d:\WORK\CODE\op2_to_vtu\op2_to_vtu.py", line 23, in
nastran_to_vtk(model, model, vtk_filename)
File "C:\Users\guotao\AppData\Roaming\Python\Python312\site-packages\pyNastran\converters\nastran\nastran_to_vtk.py", line 268, in
nastran_to_vtk
gui.load_nastran_geometry(bdf_filename)
File "C:\Users\guotao\AppData\Roaming\Python\Python312\site-packages\pyNastran\converters\nastran\gui\nastran_io.py", line 470, in
load_nastran_geometry
skip_reading = self._remove_old_nastran_geometry(bdf_filename)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\guotao\AppData\Roaming\Python\Python312\site-packages\pyNastran\converters\nastran\gui\nastran_io.py", line 350, in
_remove_old_nastran_geometry
if bdf_filename is None or bdf_filename == '':
File "C:\Users\guotao\AppData\Roaming\Python\Python312\site-packages\pyNastran\op2\op2.py", line 194, in eq
is_equal = self.assert_op2_equal(op2_model,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\guotao\AppData\Roaming\Python\Python312\site-packages\pyNastran\op2\op2.py", line 237, in assert_op2_equal
if not self.read_mode == op2_model.read_mode:
^^^^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'read_mode'

Looking forward to your reply, thank you.

SteveDoyle2 commented 4 months ago

I thought I replied 2 days ago.

I assumed it worked the way I had documented, but it required a BDF. I went through and fixed the issues that I found (so it can take a Path now as well as a string, a BDF, and and OP2Geom).