Hi,
I am just starting to use the opensim API for matlab. I have a line of code in python which I am trying to convert to matlab. However, I missing a specific part for the matlab code. I was trying now for hours to get a results and finally ended up with getting help here in the forum : ) Any hints more than appreciated:
Python version:
femContact = osimModel.getContactGeometrySet().get('femur_cartilage')
femContactMesh = osim.PropertyString_getAs(femContact.getPropertyByName('mesh_file')).getValue()
What I was not able to find in Matlab was the part 'PropertyString_getAs' - does anyone have an idea how this needs to be done in matlab?
Thank you, Brian
Translating python API code to matlab
- Brian Horsak
- Posts: 3
- Joined: Fri Sep 08, 2017 4:00 am
- Ayman Habib
- Posts: 2248
- Joined: Fri Apr 01, 2005 12:24 pm
Re: Translating python API code to matlab
Hello,
Not sure what version of openSim code/API you're using but what you need to do is something along the lines below in version 4.0+:
You should check the doxygen documentation (accessible through the GUI/Application and/or methodsview() in Matlab) of the version you're using to find out what methods/classes are available.
Best regards,
-Ayman
Not sure what version of openSim code/API you're using but what you need to do is something along the lines below in version 4.0+:
Code: Select all
femContact = osimModel.getContactGeometrySet().get('femur_cartilage') #will return a ContactGeometry
meshContact = osim.ContactMesh.safeDownCast(femContact) # make it into a proper ContactMesh that's aware of mesh files
femContactMeshFile = meshContact.get_filename(0) # get mesh file name from ContactMesh
Best regards,
-Ayman