Retrieve Visible Object Files Attached to Body Objects in MATLAB 4.0 API

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Connor Pyles
Posts: 20
Joined: Wed Jul 19, 2017 1:46 pm

Retrieve Visible Object Files Attached to Body Objects in MATLAB 4.0 API

Post by Connor Pyles » Wed Jul 26, 2017 1:16 pm

Hello,

I am working on some MATLAB code which uses the OpenSim 4.0 API to read in an existing model, but I can't figure out how to get the visible object files associated with each body.

Right now I have:

Code: Select all

% Import opensim classes
import org.opensim.modeling.*

% Read in model from file
model_file = 'my_model_file.osim;
model = Model(model_file);

% Get a body
body = model.getBodySet().get(0);

% Get geometry
geometry = body.get_attached_geometry(0);
geometry.getAbsolutePathName
But this doesn't return the path to the .vtp file I am expecting. Is there another way I should be doing this?

Thanks,
Connor Pyles
Johns Hopkins Applied Physics Lab

User avatar
Thomas Uchida
Posts: 1793
Joined: Wed May 16, 2012 11:40 am

Re: Retrieve Visible Object Files Attached to Body Objects in MATLAB 4.0 API

Post by Thomas Uchida » Wed Jul 26, 2017 1:48 pm

If the Geometry is a Mesh, you can use Mesh::getGeometryFilename() (http://myosin.sourceforge.net/1843/clas ... 41677bcba7). (Note that you will need to safeDownCast from Geometry to Mesh. Not all Geometry objects have a filename.)

User avatar
Connor Pyles
Posts: 20
Joined: Wed Jul 19, 2017 1:46 pm

Re: Retrieve Visible Object Files Attached to Body Objects in MATLAB 4.0 API

Post by Connor Pyles » Thu Jul 27, 2017 11:23 am

Worked like a charm, thanks Tom.

-CP

POST REPLY