Toggle object visibility through Matlab API

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Hangil Lee
Posts: 5
Joined: Tue Jul 24, 2018 3:32 am

Toggle object visibility through Matlab API

Post by Hangil Lee » Mon Mar 29, 2021 11:50 pm

Hi, I am editing a model through Matlab and struggling with understanding seemingly basic functions through doxygen.
I added wrap objects, but I want to hide the objects so the geometries do not show when viewing the model in OpenSim. I know I can manually hide them in the OpenSim GUI, but I would like to streamline it through Matlab.

I checked doxygen and found that "Appearance" is listed as a property under OpenSim::WrapObject, but I am having difficulty understanding how to access the "visible" property.

My guess was to use the function "set_Appearance(const Appearance & value)" to access "visible", but am not having any luck.

Any help or tips on understanding how to use doxygen as a reference for scripting would be greatly appreciated.

Tags:

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

Re: Toggle object visibility through Matlab API

Post by Ayman Habib » Tue Mar 30, 2021 10:55 am

Hello,

You're on the right track. "Appearance" is an object that has methods to set visibility (

Code: Select all

set_visible
) so you should call

Code: Select all

upd_Appearance()
to get a reference to the Appearance of the WrapObject and then call set_visible on the returned Appearance.

Always a good idea to refer to the Doxygen documentation for your specific version for the list of available methods or use methodsview in Matlab.

Hope this helps,
-Ayman

User avatar
Hangil Lee
Posts: 5
Joined: Tue Jul 24, 2018 3:32 am

Re: Toggle object visibility through Matlab API

Post by Hangil Lee » Tue Mar 30, 2021 7:07 pm

Thank you for the quick reply! Using upd_Appearance() to create a reference worked perfectly.

In this case, would there be a way to implement set_Appearance() instead? Or in general is it better practice to use upd_ to set parameters.

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

Re: Toggle object visibility through Matlab API

Post by Ayman Habib » Wed Mar 31, 2021 9:16 am

Hi Hangil,

Generally the API uses "upd_*" methods to get a writable reference to existing objects that will be modified. Using "upd_" methods when modifying an object makes sure that downstream side-effects take place in orderly fashion.

Using "set_Appearance" method here will also work but you're making a new Appearance object, populating it then copying all properties when in fact all you want to do is change one property value of an existing Appearance object.

Hope this helps,
-Ayman

User avatar
Hangil Lee
Posts: 5
Joined: Tue Jul 24, 2018 3:32 am

Re: Toggle object visibility through Matlab API

Post by Hangil Lee » Wed Mar 31, 2021 10:05 pm

Ah that makes sense. Thank you for the kind explanation!

POST REPLY