Hi, this question is related to my question in viewtopic.php?f=91&t=16752
I am updating muscle paths in a model.
The problem is that stating
"state = model.initSystem()"
before "loc=model.getMuscles().get(muscle).getGeometryPath().getPathPointSet().get(point).getLocation(state)",
does not allow for an automatic update of the model.
What do I need to do to update the default model state so that I can export the updated model to a .osim file?
Update Muscle Path
- Nicos Haralabidis
- Posts: 196
- Joined: Tue Aug 16, 2016 1:46 am
Re: Update Muscle Path
Hello Ekaterina!
I just did some exploring and maybe this works (Matlab):
import org.opensim.modeling.*
mod = Model('gait2392_simbody.osim');
state = mod.initSystem();
musc0 = mod.getMuscles().get(0)
gp0=musc0.getGeometryPath();
cp0 = gp0.getCurrentPath(state);
cp0_0 = cp0.get(0); %0th pathpoint, returns abstract pathpoint
pathpoint0 = PathPoint.safeDownCast(cp0_0); % need to downcast to concrete class to edit
pathpoint0.set_location(Vec3(1,2,3)); % 1,2,3 the new locations of the path points
state = mod.initSystem(); % Reinitialize state for changes to take effect
mod.print('test.osim'); % Print to model file to see if changes worked
Hope that works!
Thanks,
Nicos
I just did some exploring and maybe this works (Matlab):
import org.opensim.modeling.*
mod = Model('gait2392_simbody.osim');
state = mod.initSystem();
musc0 = mod.getMuscles().get(0)
gp0=musc0.getGeometryPath();
cp0 = gp0.getCurrentPath(state);
cp0_0 = cp0.get(0); %0th pathpoint, returns abstract pathpoint
pathpoint0 = PathPoint.safeDownCast(cp0_0); % need to downcast to concrete class to edit
pathpoint0.set_location(Vec3(1,2,3)); % 1,2,3 the new locations of the path points
state = mod.initSystem(); % Reinitialize state for changes to take effect
mod.print('test.osim'); % Print to model file to see if changes worked
Hope that works!
Thanks,
Nicos
- Ekaterina Stansfield
- Posts: 9
- Joined: Mon Jul 03, 2017 5:37 am
Re: Update Muscle Path
Thank you -- I will give it a go!