Page 1 of 1

Visualizer properties

Posted: Wed Jun 12, 2024 9:31 am
by rizab34
Hi,

I like to visualize my model using the Visualizer class, change background and view direction, and save the resulting image in an automated fashion. So far, I can view the model using the code pieces below, but could not change background or view direction. Is this possible in OpenSim? I am using Python v3.11 and Opensim v4.4 that I installed with Conda. Also, I need to display the model while it is oriented on the sagittal plane (like -Z button in the OpenSim Visualizer Window). However, none of the view direction options in the Visualizer class when using Python API achieve that when changing it manually.

Code: Select all

model_path      = 'C:\\Projects\\mymodel.osim'
geometry_path = 'C:\\Projects\\Geometry'
model               = osim.Model(model_path)

osim.ModelVisualizer.addDirToGeometrySearchPaths(geometry_path)
model.set_ForceSet(osim.ForceSet())
model.setUseVisualizer(True)

state = model.initSystem()

viz = model.updVisualizer().updSimbodyVisualizer()
viz.setBackgroundColor(osim.Vec3(1, 1, 1))
model.getVisualizer().show(state)