Dear All:
I try to use OpenSim API ScaleTool to scale models.The code is as:
ScaleTool scl_tol();
scl_tol.setSubjectMass(72.6);
There is unhandled exception in VC++ when "scl_tol.setSubjectMass" is being executed. Maybe due to the ScaleTool is not successfully constructed?
Even if I add a xml scale setting file (proved ok to use in OpenSim GUI) as a parameter to construct the ScaleTool object, the unhandled exception problem is still the same when executing setSubjectMass!
Thank you for anyone who can help!
ScaleTool object constructing problem in OpenSim API
- Thomas Uchida
- Posts: 1792
- Joined: Wed May 16, 2012 11:40 am
Re: ScaleTool object constructing problem in OpenSim API
I haven't worked with the ScaleTool in the API, but it's used in testScale.cpp (https://github.com/opensim-org/opensim- ... tScale.cpp). Following that example, I would try the following:
Code: Select all
std::unique_ptr<ScaleTool> scl_tol(new ScaleTool());
scl_tol->setSubjectMass(72.6);
Re: ScaleTool object constructing problem in OpenSim API
Dear Dr Uchida:tkuchida wrote:I haven't worked with the ScaleTool in the API, but it's used in testScale.cpp (https://github.com/opensim-org/opensim- ... tScale.cpp). Following that example, I would try the following:Code: Select all
std::unique_ptr<ScaleTool> scl_tol(new ScaleTool()); scl_tol->setSubjectMass(72.6);
Thank you so much for your kind reply!
The problem is still the same when I use "std::unique_ptr<ScaleTool>". I am not sure why the object construction has such issue and cannot perform the method function.
Thanks & Regards,
Jack
- Thomas Uchida
- Posts: 1792
- Joined: Wed May 16, 2012 11:40 am
Re: ScaleTool object constructing problem in OpenSim API
Based on your other recent post, I'm guessing that you're using 3.2. In the 3.2 distribution, the analogous code in testScale.cpp would be something like the following:
Depending on what you're trying to accomplish, you might consider using the GUI to create an initial setup file and modifying only the necessary fields in MATLAB—either using the OpenSim API or by editing the .xml as a text file.
Code: Select all
ScaleTool* scaleTool = new ScaleTool("scale_tool_setup_file.xml");
Model* model = scaleTool->createModel();
scaleTool->setSubjectMass(72.6);
delete model;
delete scaleTool;