Page 1 of 1

Set value of AbstractProperty

Posted: Tue Jan 28, 2020 9:49 pm
by ajyoder
I need to change the value of an object's property programmatically using MATLAB API

The object is a custom controller defined in a plugin dll, so I can't use safeDownCast to use concrete methods, as explained here:
viewtopicPhpbb.php?f=91&t=7281&p=19121&start=0&view=

I can load a model containing the custom controller just fine and access the gain I want to adjust as an AbstractProperty

Code: Select all

controller=model.getControllerSet.get('CustomReflexController');
gain=controller.updPropertyByName('gain');
The only two relevant AbstractProperty methods i see in methodsview() are updValueAsObject(index) and setValueAsObject(index) neither of which seem to work:

Code: Select all

gain.updValueAsObject(0)=5

Unrecognized property 'updValueAsObject' for class 'org.opensim.modeling.AbstractProperty'.
Doesnt look like correct MATLAB syntax, but was suggested in another post
viewtopicPhpbb.php?f=91&t=10913&p=30255&start=0&view=

Code: Select all

gain.updValueAsObject(0)

Java exception occurred:
java.lang.RuntimeException: SimpleProperty<T>::updValueAsObject(): property gain is not an Object property.
at org.opensim.modeling.opensimModelJNI.AbstractProperty_updValueAsObject__SWIG_0(Native Method)
at org.opensim.modeling.AbstractProperty.updValueAsObject(AbstractProperty.java:96)
The "Container Interface" section here
https://simtk.org/api_docs/opensim/api_ ... perty.html

Thanks in advance!

Re: Set value of AbstractProperty

Posted: Wed Jan 29, 2020 8:46 am
by tkuchida
Please see the Matlab code I posted in Topic 9609: viewtopicPhpbb.php?f=91&t=9609

Re: Set value of AbstractProperty

Posted: Thu Jan 30, 2020 10:16 am
by ajyoder
awesome that works (using osim3.3)

for those wondering PropertyHelper was deprecated in osim3.1 but doc can be found here:
https://simtk.org/api_docs/opensim/api_ ... elper.html

Re: Set value of AbstractProperty

Posted: Mon May 04, 2020 5:12 am
by brycekillen05
HI Tom,

I followed the link you have provided and as posted above this work for 3.3 implementation, but in 4.0 PropertyHelper seems to be Depricated. Is there a OpenSim4.0 equivalent ?

The only property class I have been able to access is PropertyString - which helps when I am trying to access information - but writing, for example, a double does not work using this class. There is apparently PropertyDbl - but I cannot seem to access it, and it is not even listed in the OpenSim API class list.

Thank you in advance for any information you can provide

Bryce