Page 1 of 1

can not remove muscles

Posted: Wed Sep 22, 2021 7:35 pm
by s.ramezani
Hi,
I'm trying to remove some muscles from model. It does not give me error and before printing model when I check number of muscles it seems they have been removed however, after printing model, there is no changes. Do I need to finalize or something like that before printing? my code is

Code: Select all

import org.opensim.modeling.*;
Logger.addSink(JavaLogSink());
osismmodel = Model('subject_walk_armless.osim');
osismmodel.finalizeConnections();
SimMusclename=["bflh_r","bfsh_r","gaslat_r"]
c=0;
for m = 0:osismmodel.getMuscles().getSize()-1
        musc = osismmodel.updMuscles().get(c);
        if ~sum(strcmp(char(musc.getName()), SimMusclename))
        osismmodel.updMuscles().remove(c)
        else
            c=c+1;
        end
end
osismmodel.print('subject_walk_armless_DeGroote.osim');

Re: can not remove muscles

Posted: Thu Sep 23, 2021 12:32 am
by nassila
Hi,

I had a similar issue, except I work with python, so I am not sure the solution would be the same.
In my case, I had to update the model's ForceSet, instead of the muscle set, to be able to successfully save it in the new osim file.

Hope it helps,

Najoua

Re: can not remove muscles

Posted: Thu Sep 23, 2021 7:56 am
by s.ramezani
Thanks Najoua, it worked.