Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • You can change the location of the Scripts directory by going to Edit > Preferences... and changing the directory under the "ScriptsPathPath: Scripts Path" option (see User Preferences for more information). 
    • Directories are relative to the OpenSim installation Directory (e.g. Specifying "MyScripts" will look for scripts in the folder C:\ProgramFiles\OpenSim3.0\MyScripts if you installed OpenSim in the folder C:\ProgramFiles\OpenSim3.0). 
    • Note that you have to restart OpenSim for the change to take placeNote that you have to restart OpenSim for the change to take place.
    • The default value is <ResourcesDir>/Code/GUI, and the value is reset if you run installResources() in the ScriptingShell.
    • In the ScriptingShell, you can access the value of this preference using getScriptsPath().
  • After loading a script, variables defined in the script are available for future reference.
  • A panel to echo commands and files executed in the scripting shell is available   (the "Command History"). You can clear the command history by right clicking in the window and selecting "Clear".
  • If there are errors in running a script from file, you can view the corresponding error messages by clicking on the red error icon in the bottom right of the OpenSim screen, and then selecting "Show Details"
  • In the GUI scripting shell, code executed as part of for loops or if statements is controlled by indentation, rather than braces as in C++ or the for/end convention in Matlab. Otherwise, at the ScriptingShell command prompt, you must enter one line at a time.

...

Script NameDescription
runTutorialOne.pyThis example script performs the steps performed in Tutorial 1 - Intro to Musculoskeletal Modeling.
runTutorialTwo.pyThis example script performs the steps performed in Tutorial 2 - Simulation and Analysis of a Tendon Transfer Surgery.
runTutorialThree.pyThis example script performs the steps performed in Tutorial 3 - Scaling, Inverse Kinematics, and Inverse Dynamics.
testShowModelSummary.pyDisplays information about the current model in a standalone dialog.
plotMuscleFiberLengthAgainstFile.py

Shows how to create and display a plot window. The script loads the BothLegs OpenSim model and adds curves of fiber length for the model. Then, it loads and plots data from a storage file, which contains fiber lengths for the model Subject01_simbody that is included with the OpenSim distribution.

plotMuscleMomentArmAgainstMotion.pyShows how to plot muscle moment arms as a function of a motion.
makeUlnaHeavy.pyShows how to create a modified version of a model that is loaded in the GUI. The script increases the mass of the ulna. The modified model is then loaded in the GUI.
alterTendonSlackLength.pyShows how to change the attributes of the muscles for the current model.
runScaling.pyRuns the scale tool for the Gait2354 model, and loads the generic and scaled models in the GUI.

runMultipleIKTrials.py

Runs multiple inverse kinematics trials. To see the results, load the model and IK output in the GUI.
strengthenModel.py

Increases the max. isometric force of all the muscles in the currently loaded model. A pop-up dialog displays a confirmation with the name of the new model.

editProperties.pyScript to demonstrate how to edit model component properties.
modelBuildingUtilitiesModelBuilder.pyHelper functions for adding specific types of components (Bodies, Frames, Joints, Geometry) to a model.
createControlsFromStorage.pyHelper function to create a controls.xml file from a .sto file.
Panel
borderColorgray
bgColorwhite
borderWidth5
borderStylesolid

Next: Scripting with Matlab

Previous: Common Scripting Commands Scripting Versions of OpenSim C++ API Calls

Home: Scripting and Development