- This topic has 1 reply, 2 voices, and was last updated 3 years, 2 months ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.
Home › Forum › SOFA › Programming with SOFA › How to modify and object in the scene and restart simulation
Tagged: Sofa programming, SOFA_2106, Windows_10
Hi,
I am using SofaPython3 doing a project. Currently I need to store data of simulation with different force field. Therefore, I want to automatically change force field and restart the simulation several times. My idea is create controller to change forcefield, and in
main loop, change forcefield and restart simulation.
def createScene():
.....
def forceManage(Sofa.Core.Controller):
def __init__(self, forcefield):
...
def changeForce():
...
def main():
root = Sofa.Core.Node("root")
createScene(root)
child = getObject of root.getChild("child")
a = forceManage(child.Forcefield)
for loop:
a.changeForce()
Sofa.Simulation.init(root)
if __name__ == '__main__':
main()
But the problem is that I don’t know how to getObject of scene node in main loop, I actually find the function of node called getObject, but it does not work in the main loop(maybe it does not work with sofaPython3?) So I was wondering how to do that? or any better suggestions to realize my function?
Another question is general, I found difficult to know what I can do in Sofa? do you have any suggestions to learn Sofa?
Thank you very much!
Best wishes,
YUAN
Hi @qdyuan4619
Have you looked at the forcefield example in the SofaPython3?
Else regarding restarting a simulation in python, @PierreShg may help on this. It could cool to have an example of this in the SofaPython3 plugin!
Hugo
WARNING
The forum has been moved to GitHub Discussions.
Old topics and replies are kept here as an archive.