Thanks for the tips. Unfortunately, the user guide doesn't offer too much help and I'm still searching GitHub for any code that might be inuitive to work from. I've tried working from 'runScaling.py' file before but Christopher Dembia mentioned that it was for GUI scripting as I couldn't find the 'getResourcesDir()' object. Nonetheless, I thought that there might be some way around modifying the 'runScaling.py' to work in Spyder.
So far I've been playing around with two bits of code but it's sorta feels like I'm stabbing in the dark with different iterations:
Code: Select all
import opensim as osim
import os.path
myModel = osim.Model('Strong_Model.osim')
myState = myModel.initSystem()
scaleSetupPath = os.path.join('C:\OpenSim 4.0\Resources\Scrap code', 'Setup_Scale.xml');
scaleTool = osim.ScaleTool(scaleSetupPath)
scaleTool.run()
with error:
File "C:\Users\pscob\AppData\Local\Continuum\anaconda2\lib\site-packages\opensim-4.0-py2.7.egg\opensim\tools.py"
, line 4100
, in run
return _tools.ScaleTool_run(self)
RuntimeError: std::exception in 'bool OpenSim::ScaleTool::run() const': scale: ERROR- No model specified.
and
Code: Select all
import opensim as osim
import os.path
myModel = osim.Model
myState = myModel.initSystem() ('Strong_Model.osim')
scaleTool = osim.ScaleTool('Setup_Scale4.xml')
myModel = osim.Model('Strong_Model.osim')
myModel.initSystem()
state = myModel.initSystem();
scaleTool.setSubjectMass(85)
scaleTool.setSubjectHeight(171);
scaleTool.setSubjectAge(30);
scaleTool.getModelScaler().setApply(True);
scaleTool.getModelScaler().setMarkerFileName('Markerset.xml');
scaleTool.getModelScaler().setPreserveMassDist(True);
scaleTool.getModelScaler().setPrintResultFiles(True);
scaleTool.getModelScaler().setOutputModelFileName('Strong_Model3.osim');
scaleTool.getModelScaler().setOutputScaleFileName('Setup_Scale5.xml')
path2subject = scaleTool.getPathToSubject()
scaleTool.getModelScaler().processModel(state, myModel, path2subject, ());
state = myModel.initSystem();
scaleTool.run();
with error:
File "C:\Users\pscob\AppData\Local\Continuum\anaconda2\lib\site-packages\opensim-4.0-py2.7.egg\opensim\tools.py"
, line 3222
, in processModel
return _tools.ModelScaler_processModel(self, *args)
NotImplementedError: Wrong number or type of arguments for overloaded function 'ModelScaler_processModel'.
Possible C/C++ prototypes are:
OpenSim::ModelScaler::processModel(OpenSim::Model *,std::string const &,double) const
OpenSim::ModelScaler::processModel(OpenSim::Model *,std::string const &) const
OpenSim::ModelScaler::processModel(OpenSim::Model *) const