Welcome to ask.woodem.org. You may post when you login through your GitHub account.

Save and Run from the Gnenerator

0 votes
asked Oct 19, 2016 by MarcoTar (770 points)

Hi Vaclav

Here I have the last several questions to ask you before ending my thesis

Here's the description:

As I mentiond before, I've created the Membrane , and soil grains ( through sphere.pack)

First of all, let the spheres drop to the membrane and until all the spheres settle to the membrane then I Save this Situation through 'Save' option form the Generator (F9)

Secondly, I load this situation (this works) and I add one big Sphere to this situation through

from past.builtins import execfile


Here's the question:

the RockFall.py script doesn't contain like the 'from woo import*, import minieigen' which the module has already used in the 1st py script (the save situation script). So the RockFall.py cannot be added to this scene. It will show the error like 'name pi is not defined'

Any idea?

I want to add something to this situation in order to avoid run the particle dropping to the membrane every time.

Thanks a lot

Best Regards

Feixiang Xuan

1 Answer

0 votes
answered Oct 20, 2016 by eudoxos (49,070 points)

Hi, what you do with execfile makes no sense; I see you don't understand how scripting in Woo (or in general in programs like blender etc which also embed Python), which is OK, I explain how to what you want.

  1. You save your resulting simulation (spheres are deposited) using S.save into some file, call it e.g. a.bin.gz or whatever (.bin.gz will stores it as compressed binary); what you do by hand by clicking save is essentially the same.
  2. Then you create another script, which will start like this:
    import woo,woo.core,woo.dem
    # do other imports here etc, that is not something saved with the simulation
    # because it is really python interpreter state, not simulation
    from minieigen import *
    # ...
    # this loads the scene you saved before
    # sets the master scene (which you see in the GUI) to be this scene
    # and also assigns it to "S" which you can use afterwards
    # do your stuff here, such as adding the new sphere to the simulation
    # just like usual
    # engines are already set up from a.bin.gz -- unless you need to change something
    # now you can run with the new sphere
    # either by clicking from the GUI or calling S.run() here


There is one caveat you should know about: the savefile format is nothing guaranteed to be stable. It can happen you won't be able to open it after you update Woo, see details in the manual. The scripts, on the other hand, will continue to work (minus rare and documented changes).