1. NodeBox 1
    1. Homepage
    2. NodeBox 3Node-based app for generative design and data visualization
    3. NodeBox OpenGLHardware-accelerated cross-platform graphics library
    4. NodeBox 1Generate 2D visuals using Python code (Mac OS X only)
  2. Gallery
  3. Documentation
  4. Forum
  5. Blog

Console

Using NodeBox in another application

The NodeBox core is now split off from the UI functionality, so you can use it in any project. There are a few different ways of using NodeBox.

1. The easy way: from NodeBox itself

One of the new features in NodeBox is that you can access the canvas object. It's a list-like structure, containing all your graphical objects ("grobs"). The canvas also has a "save" method, so anywhere in your script you can do:

canvas.save("partial.pdf")

And it will save what it has drawn up until that point. Do it at the end of your script, and you get the full output.

After saving, you might want to clear out the canvas. You can:

canvas.clear()

This will remove all grobs already on the canvas; they will not show up in the render.

2. Installing the NodeBox module

If you want to use NodeBox from the command line, you will have to install it. We currently recommend using Subversion to grab a copy:

svn co http://dev.nodebox.net/svn/nodebox/trunk/ nodebox
cd libs/Numeric
python setup.py install
cd ../..
 
cd libs/pathmatics
python setup.py install
cd ../..
 
cd libs/polymagic
python setup.py install
cd ../..
 
cd src
python setup.py install

The only outside dependency is PyObjC. We recommend the latest version from Subversion.

3. Using the console runner

When you have a set of NodeBox scripts that you want to run to generate images or a movie, use the following commands:

from nodebox import console
source = "size(200,200)\nrect(random(WIDTH), random(HEIGHT), 20, 20)"
console.make_image(source, "rect.png")
console.make_movie(