Page 1 of 1

Changing manual scaling factors using MATLAB API

Posted: Wed Dec 05, 2018 11:18 pm
by okvsh
Hello,

I would be grateful if someone could tell me how to change manual scale factors using MATLAB and OpenSim 4.0.
I would like to systematically change manual scaling factors defined in a ScaleTool object (below is the corresponding part in an .xml file) to generate models with different knee heights with the same leg length.
<ModelScaler>
<Scaleset>
<Scale>
<scales> 1 1 1</scales>
<segment>femur</segment>
<apply>true</apply>
</Scale>
...
I could get access to the property, but cannot find the way to change the list values in the AbstractProperty class.
I think there would be a more sophisticated way to get access and update the values. I would appreciate any advice.

Code: Select all

a = ScaleTool(filepath)
b = a.getModelScaler();
c = b.getScaleSet();
d = c.getPropertyByIndex(0); % 0:  <segment>femur
e = getValueAsObject(0); % 0: <scales> 
manualScaleFactorsForFemur = get PropertyByIndex(0);
Kind regards,
Yusuke Okita

Re: Changing manual scaling factors using MATLAB API

Posted: Thu Dec 06, 2018 11:56 am
by jimmy
You will have to safedowncast to the concrete class

Code: Select all

scaleObject = Scale.safeDownCast(e)
scaleObject.setScaleFactors( Vec3(1,1,1) )

Re: Changing manual scaling factors using MATLAB API

Posted: Thu Dec 06, 2018 9:05 pm
by okvsh
I could successfully change scaling factors according to your advice. Thank you!