- This topic has 3 replies, 2 voices, and was last updated 3 years, 5 months ago by .
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
- You must be logged in to reply to this topic.
Home › Forum › SOFA › Programming with SOFA › [SOLVED] Issue with the update of the stiffness variable in StiffSpringFF
Tagged: SOFA_1906, stiffness parameter, Windows_10
Hello everyone,
I am currently using StiffSpringForceForce. I succeed to create a spring in my scene using: LSrtgFF1=MecaModelNode.createObject('StiffSpringForceField', name='StiffSprgFF1', template='Rigid3d', spring=""+str(numberElement)+" "+str(numberElement+1)+" "+str(SpringStiffness)+" 0 0")
I tried to modify the stiffness parameters inside a controller. First using the same line but I could access the date so I tried with another method. I tried to modify it directly by changing the stiffness component as we can do in the user interface.
if key == Key.uparrow:
self.SpringStiffness=self.SpringStiffness-StiffnessOffset
self.LSrtgFF.stiffness=str(self.SpringStiffness)
The problem is the following: the stiffness parameter is changing but the spring’s value Ks is not updated.
Do you know what could be the problem ?
Benjamin
Hey @benjamin,
It looks like this component stores its spring parameters at the beginning of the simulation and does not automatically update them when the stiffness data field changes.
Can you try manually calling the “reinit” method of the object just after changing its stiffness? Something like:
self.LSrtgFF.stiffness=str(self.SpringStiffness)
self.LSrtgFF.stiffness.reinit()
Hi @jnbrunet,
Thank you so much for your answer! It is working well now. My apologies for asking for your help. I should have looked at the .h file of SpringStiffness to find the solution..
Benjamin
Awesome, thanks for your feedback Benjamin. I’ll mark this topic as resolved then.
WARNING
The forum has been moved to GitHub Discussions.
Old topics and replies are kept here as an archive.