← Back to team overview

yade-users team mailing list archive

Re: [Question #261965]: Saving/loading simulations

 

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

    Status: Open => Answered

Bruno Chareyre proposed the following answer:
>this is a feature of Yade

More exactly, it is a feature of python:
me@desktop:~$ python                                                                                                                                                
>>> def helloWorld(): print "hello world!" 
>>> helloWorld()
hello world!
>>> quit()
me@desktop:~$ python
>>> helloWorld()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'helloWorld' is not defined

One solution is this:

me@desktop:~$ echo "def helloWorld(): print 'hello world!'" > hello.py
me@desktop:~$ python 
>>> from hello import *
>>> helloWorld()
hello world!

@Behzad, the simplest way is to define addData() in the script applying
the load. In many cases it makes more sense actually, because you don't
need the evolution of position before the loading, or at least you don't
want it duplicated in the output of each other loading.

Side points:
- Could you explain why you had the idea of saving in xml? It is a bad idea but it is seen frequently. If there is something in the documentation that pushed you toward this we should fix it. Better save as *.yade, or *.yade.gz, much faster and less disk usage.

- "from yade import utils" is useless and can be the source of troubles.
Remove  also the "utils." prefix in the script.

-- 
You received this question notification because you are a member of
yade-users, which is an answer contact for Yade.