Binary .vtp files to ascii for geometry files

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Katie Blessinger
Posts: 14
Joined: Mon Sep 13, 2021 11:21 am

Binary .vtp files to ascii for geometry files

Post by Katie Blessinger » Tue Mar 22, 2022 9:48 am

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
Attachments
ASCIIerror4forum_python.JPG
error from vtk module in python
ASCIIerror4forum_python.JPG (48.51 KiB) Viewed 370 times
ASCIIerror4forum.JPG
error in OpenSim
ASCIIerror4forum.JPG (53.71 KiB) Viewed 370 times

Tags:

User avatar
Ayman Habib
Posts: 2235
Joined: Fri Apr 01, 2005 12:24 pm

Re: Binary .vtp files to ascii for geometry files

Post by Ayman Habib » Tue Mar 22, 2022 12:23 pm

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

User avatar
Katie Blessinger
Posts: 14
Joined: Mon Sep 13, 2021 11:21 am

Re: Binary .vtp files to ascii for geometry files

Post by Katie Blessinger » Thu Mar 24, 2022 5:55 am

thanks!

User avatar
Bryce Killen
Posts: 104
Joined: Mon Nov 24, 2014 7:12 pm

Re: Binary .vtp files to ascii for geometry files

Post by Bryce Killen » Mon Mar 28, 2022 5:35 am

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 .. ')

POST REPLY