Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
-
Jenny Manteli
- Posts: 1
- Joined: Tue Mar 12, 2019 4:19 am
Post
by Jenny Manteli » Tue Mar 12, 2019 4:29 am
Hello community,
I'm working on some new modifications within the GUI. What I try to realize is an automatic script execution to add new bodies. For that I created a python script. If I execute it manually via GUI and Scripts > Run it works without problems.
Now I am trying to use a PythonInterpreter that executes it automatically when clicking on a button. I created a "helper" package similar to the Scripting Shell Subproject for that. First it executes ModelBuildingFunctions.py; second it should execute a CreateNewBody.py script that adds a sphere.
Unfortunately it does not work as I expected. I get this error:
Code: Select all
Traceback (most recent call last):
File "../../../../CreateNewBody2.py", line 9, in <module>
model = getCurrentModel().clone()
NameError: name 'getCurrentModel' is not defined
I am not very familiar with python, so I am a bit clueless why it does not work. Do you have any idea what sort of access is missing here?
Tags:
-
Bryce Killen
- Posts: 104
- Joined: Mon Nov 24, 2014 7:12 pm
Post
by Bryce Killen » Wed Apr 17, 2019 8:56 pm
Hi Jenny,
I can't say i'm fully familiar with your problem but I have worked with the Python API in OpenSim 3.3 . Just to clarify, are you trying to run the script as a standalone .py script through Anaconda or through the OpenSim GUI ?
From what I can see, you are trying to run the function, getCurrentModel() , looking at the OpenSim 4.0 doxygen page
https://simtk.org/api_docs/opensim/api_docs/, I can't actually see that function. I'm not sure if there is a different set of functions available when running through the GUI vs standalone python scripts.
If you are able to clarify where you are running your script this might start to get to the bottom of the problem.
Cheers
-
jimmy d
- Posts: 1375
- Joined: Thu Oct 04, 2007 11:51 pm
Post
by jimmy d » Thu Apr 18, 2019 6:54 am
The GUI shell is Jython interpreter and has a lot of calls that are only native to GUI shell-- getCurrentModel() can only be called in the GUI.