Python

From K-3D

Jump to: navigation, search

Description

Python scripting engine
Plugin Status:Stable
Categories:All Plugins, Stable Plugins, ScriptEngine Plugins

Metadata

Name Value
k3d:mime-types text/x-python


Overview

The Python scripting engine fully integrates the popular Python scripting language into K-3D. Python (http://www.python.org) is already used extensively in the scientific and graphics communities (among many others), combining a powerful multi-paradigm language with an expansive collection of runtime libraries. A comprehensive object model exposes all K-3D features for complete, detailed control by scripts written in Python.

Syntax

Because K-3D supports multiple scripting languages, programs written in Python must begin with the literal #python at position zero within the program sources, so K-3D can identify them for playback by the correct script engine.

Object Model

K-3D's object model is packaged for use within scripts as a Python module named k3d. Most K-3D Python scripts will import the k3d module near the beginning of a script for later access to K-3D's features:

#python

import k3d
k3d.ui().message("howdy, world!")

Documentation

For a discussion of the many ways in which you can use scripting in K-3D, see Scripting. The K-3D Python object model documentation is generated automatically from the sources and located at http://www.k-3d.org/docs/epydoc

Sample Scripts

There are many sample scripts written in Python located in the k3d/share/scripts directory and its subdirectories. In addition most of the regression test scripts located in the k3d/tests directory are written in Python.

References

A comprehensive Python documentation :

A good resource for 3D programming in python

Some useful python modules :

  • Python Imaging Library (PIL) for use with BitmapModifierScript and BitmapSourceScript
  • CGKit Computer Graphics Kit is a generic 3D package, can be of use with RenderManScript
Retrieved from "http://wiki.k-3d.org/Python"
Personal tools