- This topic has 4 replies, 2 voices, and was last updated 3 years, 4 months ago by .
Viewing 5 posts - 1 through 5 (of 5 total)
Viewing 5 posts - 1 through 5 (of 5 total)
- You must be logged in to reply to this topic.
Home › Forum › SofaPython3 › Using SofaPython3 › [SOLVED] Accessing deformations, force states, etc using Python
Tagged: export mesh, SOFA_2012, Windows_10
Dear all,
I want to integrate my SOFA scene into another framework, where I need to access the deformation of the mesh (& force field) in real time. I know that the VTKExporter exists to send this to a file, but is there a possibility to directly access it (e.g. with a Python Script Controller) to process the data simultaneously elsewhere?
If this is only available using the native languiage of SOFA, I should be able to handle it anyway :).
Kindest regards,
Serkan
Hey Serkan,
What data are you looking to extract from your scene? And what forcefield are you using?
Not all data are accessible from within python (and even c++), it really depends on which components your are using in your scene and if these were made to easily export such data.
Jean-Nicolas
Dear Jean-Nicolas,
thanks for your response.
I would be looking into the deformation/displacment of the mesh of a specific deformable object (in a scene with multiple objects). In addition also local force values would be interesting but this is secondary at the moment.
Edit:
I am using the ‘TetrahedronFEMForceField’
All the best,
Serkan
Hey Serkan,
You can easily get the displacement of a mesh using the SofaPython3 plugin. Here’s a quick example of a cantilever bending simulation where the mesh is exported in a vtu file alongside its current displacement and nodal Von mises stress.
https://gist.github.com/jnbrunet/79a3a9d493d2dc4458433356bc037e04
To visualize the meshes, you can open up an exported mesh file in Paraview and add the “Wrap by vector” filter (using the “u” data field) to visualize the displacement, and color the wrapped result using the “von_mises” data field.
Let me know if you run into some issues.
Jean-Nicolas
Hey Jean-Nicolas,
thank you for the example given. it helps me a lot. I will have a further look into this matter. I will mark this topic as resolved. Thank you!
All the best,
Serkan
WARNING
The forum has been moved to GitHub Discussions.
Old topics and replies are kept here as an archive.