Visualizer properties

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Riza Bayoglu
Posts: 14
Joined: Wed Aug 02, 2023 8:54 am

Visualizer properties

Post by Riza Bayoglu » Wed Jun 12, 2024 9:31 am

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)

Tags:

POST REPLY