Page 1 of 1

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

Posted: Wed Jul 26, 2017 1:16 pm
by cpyles11
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

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

Posted: Wed Jul 26, 2017 1:48 pm
by tkuchida
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.)

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

Posted: Thu Jul 27, 2017 11:23 am
by cpyles11
Worked like a charm, thanks Tom.

-CP