Page 1 of 1

AddStateVariable() method Python API

Posted: Fri May 28, 2021 1:25 am
by louislbd
Hello,

I'm working on a project where I try to customize a Component in order to add state variables to compute a spindle behaviour.
I'm working with Opensim 4.2 in a Python 3.7 environment.
My issue is that I can't find the corresponding python method to AddStateVariable found in the C++ Opensim API here :
https://simtk.org/api_docs/opensim/api_ ... 35d22014da
I checked the .py files in the sdk and printed the content of the Opensim modules thanks to the help("nameofthemodule") method but I still can't find the existence of the addStateVariable() method.
Does anyone know how to use this method in a Python environment ?

Thanks for your help,

Louis

Re: AddStateVariable() method Python API

Posted: Wed Jun 09, 2021 6:19 am
by louislbd
Hi again,

Sorry to bother people on the forum with that but I could really need some help on this point.
I tried calling the addStateVariable method through opensim.common.Component.Add... path but I get the following error message " type object 'Component' has no attribute 'addStateVariable'".

Thanks by advance,

Louis

Re: AddStateVariable() method Python API

Posted: Thu Jun 10, 2021 5:57 am
by tkuchida
As far as I know, the API does not support adding state variables from Python. Customizing a Component is typically done by building a plugin. Resources for building/using plugins can be found in the documentation:
- "Creating Plugins", https://simtk-confluence.stanford.edu/d ... ng+Plugins
- "Using Plugins", https://simtk-confluence.stanford.edu/d ... ng+Plugins
There are also a few examples in the "Resources" directory (e.g., C:\OpenSim4.0\Resources\Code\CPP\Plugins).

Re: AddStateVariable() method Python API

Posted: Thu Jun 10, 2021 6:14 am
by louislbd
Thank you for the clarification !