← Back to team overview

yade-users team mailing list archive

Re: [Question #685237]: KeyError

 

Question #685237 on Yade changed:
https://answers.launchpad.net/yade/+question/685237

    Status: Open => Answered

Jan Stránský proposed the following answer:
> So the only way to resolve this error is not to use the O.save and
O.load?

no, what I meant is not only using O.save/O.load, but save/load
plot.data, something like:

### script 1
import json
from yade import plot
O.bodies.append(sphere((0,0,0),1))
newton.gravity = (0,0,-10)
O.engines += [PyRunner(iterPeriod=1,command="plot.addData(v=O.bodies[0].state.vel)")]
O.run(5,True)
O.save("s1.yade.gz")
with open("s1.json","w") as f:
	json.dump(plot.data,f)
###

### script 2
import json
from yade import plot
O.load("s1.yade.gz")
with open("s1.json") as f:
	plot.data = json.load(f)
O.run(5,True)
print(plot.data)
###

> can I use the yade.export.text command to save the position of all the
particles and use yade.ymport.text to reload the position of the
particles.

yes, of course.
O.save / O.load saves and loads all the scene (materials, velocities, engines, ...).
So it depends on specific situation which approach to prefer..

cheers
Jan

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.