Home › Forum › SOFA › Using SOFA › [SOLVED] Deleting Springs via SofaPython3
Tagged: 64_bits, Linux_ubuntu, Plugin_other, SOFA_other, SofaPython3, Spring, StiffSpringForceField
- This topic has 5 replies, 2 voices, and was last updated 3 years, 10 months ago by Scheikl.
-
AuthorPosts
-
10 December 2020 at 18:49 #17995ScheiklBlocked
Dear SOFA Community,
I am trying to simulate two objects that are connected via connective tissue.
The easiest way to achieve a similar behavior is aStiffSpringForceField
.
I would like to delete springs in this ForceField, when a certain force on the objects is exceeded. (Look into the mechanical object at specific indices, and trigger spring deletion, onceforce
is too large.body1.addObject( "StiffSpringForceField", template="Vec3d", name="SpringForceField", object1=body1.collisionMO.getLinkPath(), object2=body2.collisionMO.getLinkPath(), indices1=[78, 34], indices2=[88, 96], length=[28.4112, 29.8606], stiffness=1e04, damping=5 ) body1.init()
When I create the scene via
runSofa
, the springs are visible in the object, and removing them during runtime works fine.As a next step, I wanted to do the same thing from within a python script.
However,print(body1.SpringForceField.spring.value)
returns[[], []]
So the general shape of the DataField is correct, but I cannot access the springs.What would be your approach to delete springs via python?
Deactivating all springs at once withbody1.SpringForceField.isCompliance = True
works fine, but I would like to delete individual springs.Cheers,
PaulSOFA version: v20.12_beta
SofaPython3 version: master (4566e4d83a126b7722cbeb824b38254e99d4cf73)16 December 2020 at 10:05 #18035jnbrunetModeratorHey @scheikl ,
I think this is because the data
spring
is a vector ofsofa::component::interactionforcefield::LinearSpring
objects, and the latter class hasn’t been bound to python3 yet, hence why you are seeing a vector of empty values (SofaPython3 detects that it is a vector, but cannot convert the LinearSpring class).If you have some time, would you be able to create a very basic python 3 scene using the
StiffSpringForceField
. By basic I mean with the minimum number of components and plugins (for example, two objects attached and created from aRegularGridTopology
so that we don’t have to add mesh files to the scene). I will try to add bindings for theLinearSpring
class and this will help me to test the bindings.J-N
18 December 2020 at 23:25 #18060ScheiklBlockedHi @jnbrunet,
sorry for the late reply!Oh okay, that makes sense.
Would a scene with default meshes from
sofa/share
be okay?
https://cloud.ipr.kit.edu/s/STwn3oAHNn4dnnGCheers,
Paul23 December 2020 at 11:26 #18079jnbrunetModerator23 December 2020 at 11:32 #1808028 December 2020 at 22:45 #18084ScheiklBlocked -
AuthorPosts
- You must be logged in to reply to this topic.