Want to export a model from OpenSim? igotchufam.
- Convert all Geometry files to STL. Either use your favorite program or if it's a VTP file, use the included converter.
python vtp2stl.py Geometry -o Geometry
should work for most models. - Edit the .osim file and change all mesh references to the new STL files. e.g. Find & Replace .vtp with .stl using your favorite text editor.
python exportSTL.py your-opensim-file.osim -o your-export-directory
default directory is outputpython exportSTL.py your-opensim-file.osim -o your-export-directory -j
exports only the meshless bodies and joints
- Python 2.7 Environment
- OpenSim Python Wrapper
- numpy
- numpy-stl
- vtk (for the vtp2stl conversion)
I highly recommend you create a new Python env in conda because of the strict Python 2.7 requirement and OpenSim's setup process
conda create -n opensin python=2.7
conda activate opensin
oractivate opensin
- Follow OpenSim 4.0 installation here (YMMV for MacOS!)
conda install numpy numpy-stl
- Optional for vtp2stl.py
conda install vtk
- reference_cube.stl: Bodies with no mesh will have that in place. Replace that with your own stl file if you prefer other brilliant shapes. Also it's not actually a cube, but it makes up the coordinate axes x, y and z.
- refernce_arrow.stl: The "arrow" will point to the joint's axis, and the "arrow's width" will point to the current angle of the coordinate.
It's a quick and dirty thing I threw together. So it only exports the first attached mesh of each body. Please extend this and help make OpenSim more friendly for engineers!
This is for the other OpenSim.