Hi,
here there are more details on the fact that my script does not run with
the flag -o.
the command:
 mayavi2 -x script.py -o
gives:
ERROR|2011-03-31 12:34:48,079|'MayaviOffscreen' object has no attribute
'new_scene'
Traceback (most recent call last):
  File "/usr/bin/mayavi2", line 413, in run_script
    execfile(script_name, g, g)
  File "script.py", line 1, in <module>
    mayavi.new_scene()
AttributeError: 'MayaviOffscreen' object has no attribute 'new_scene'

...and if I comment out the line giving the problem, the same error
appears for the following line, and so on.
(The script works fine if I take out the flag -o)
I have vtk version 5.4 on Ubuntu 10.10.

thank you for your suggestions,
   giovanni


PS: the script 'script.py' is:

for i in range(1, 14):
        mayavi.new_scene()
        s = mayavi.engine.current_scene
        #mayavi.engine.current_scene.scene.off_screen_rendering = True
        s.scene.disable_render = True
        vtk_file_reader = engine.open(u'file_0%.2d00.vtk'%i, s)
        from enthought.mayavi.modules.api import Outline, IsoSurface
        o = Outline()
        mayavi.add_module(o)
        #o.actor.property.color = 1, 0, 0
        iso = IsoSurface()
        mayavi.add_module(iso)
        #iso.actor.property.opacity = 0.4
        #
        # change viewpoint
        s.scene.camera.position = [3.9, 2.7, 6.8]
        #
        #visualize surface elements as grid:
        from enthought.mayavi.modules.surface import Surface
        surface = Surface()
        engine.add_module(surface, obj=None)
        surface.actor.property.representation = 'wireframe'
        surface.actor.property.line_width = 1.0
        #save visualization:
        #s.scene.render() # render disabled by previous command
        s.scene.save('test_0%.2d00.jpg'%i)





On Thu, 2011-03-31 at 07:36 +0200, Gael Varoquaux wrote:
> On Wed, Mar 30, 2011 at 05:45:42PM -0700, Giovanni Ghigliotti wrote:
> > 1) I have written a script 'script.py' that runs fine turning the GUI
> > on:
> >   mayavi2 -x script.py
> > and does not work with the option -o (offscreen):
> >   mayavi2 -x script.py -o
> 
> What does 'does not work mean'? If you tell a doctor that you are sick
> without giving symptoms, the doctor cannot help.
> 
> > 2) I would like to create an animation starting from this script, by
> > generating a series of images with mayavi.
> > How can I make some kind of loop in order to read my files
> > (my_file_0010.vtk, my_file_0020.vtk, ...) and generate outputs
> > (test_0010.png, test_0020.png, ...), possibly with an offscreen option?
> > I apologize for being completely new to python.
> 
> It is possible. There are several caveats, that are listed on:
> http://github.enthought.com/mayavi/mayavi/tips.html#off-screen-rendering
> 
> HTH,
> 
> Gael


------------------------------------------------------------------------------
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; 
WebMatrix provides all the features you need to develop and 
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
_______________________________________________
MayaVi-users mailing list
MayaVi-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mayavi-users

Reply via email to