Page 1 of 1

Binary .vtp files to ascii for geometry files

Posted: Tue Mar 22, 2022 9:48 am
by blessinger.1
Hi! I'm trying to convert a few geometry files used in the MoBL-ARMS model (https://simtk.org/projects/upexdyn) from binary to ascii format.

For background, when I try to open some of the bones used in the MoBL-ARMS model (in OpenSim 4.0+), I get an error that only ASCII format is accepted. (Screenshot attached.)

I'm trying to run vtpbinary2ascii.py (more info here: https://github.com/opensim-org/opensim-models/issues/38) to convert the bones that are in binary to ASCII, but am running into a Python issue. When I try to run this vtpbinary2ascii.py script, I get an error that says "no module named vtk." How do I go about installing the vtk module? I'm brand new to Python, so I'm not sure how to access this vtk module to get the vtpbinary2ascii.py working?

Thanks! If any other info would be helpful, let me know & I'm happy to share
Katie

Re: Binary .vtp files to ascii for geometry files

Posted: Tue Mar 22, 2022 12:23 pm
by aymanh
Hi Katie,

If working in python and using vtk you need to install the vtk module first, how you do that depends on your environment (e.g. conda? spyder? etc.) this falls outside the scope of OpenSim but is easily found online.

Hope this helps,
-Ayman

Re: Binary .vtp files to ascii for geometry files

Posted: Thu Mar 24, 2022 5:55 am
by blessinger.1
thanks!

Re: Binary .vtp files to ascii for geometry files

Posted: Mon Mar 28, 2022 5:35 am
by brycekillen05
Example in case you have not found one

Code: Select all

import vtk
from tkinter.filedialog import askopenfilename

binSTL = askopenfilename(title = ' Select the binary STL to convert ... ')
binSTL = str(binSTL)

stlR = vtk.vtkSTLReader()
stlR.SetFileName(binSTL)
stlR.Update()

polyData = stlR.GetOutput()

ascSTL = binSTL[:-4] + '_asc.stl'

stlW = vtk.vtkSTLWriter()
stlW.SetInputData(polyData)
#stlW.SetFileTypeToASCII()
stlW.SetFileTypeToBinary()
stlW.SetFileName(ascSTL)
stlW.Write()

print (' ASCII STL saved .. ')