Python for 3D
Many 3D applications have proprietary scripting interfaces, such as Maxscript for 3DS Max, Lscript for LightWave, and MEL for Maya. Four 3D apps have adaptations of one common language, Python, for their scripting interfaces: Animation Master (beginning with version 9), Blender (up through version 2.04), Poser (as of Pro Pack), and trueSpace (versions 4+). Python for many reasons is also an excellent standalone scripting language for creating your own quick or complex 3D-related utilities. For more about using Python with A:M and tS, see the "Scripting & Expressions" focus articles in 3D Artist issue #45.
Python is magnificent as a language for beginners as well as for experienced programmers. For advanced users, there are free add-on math, imaging, OpenGL, and other libraries that can be used to facilitate 3D graphics programming.
[_3DA#45 supplement_|_Learn Python_]
3D Scripting
Python for do-it-yourself functions & quick utilities
Supplement to 3DA#45 page 4 article by Bill Allen
As an example of a situation where an artist might like to create a quick custom utility using a scripting language such as Python, this article shows a tiny script to put a GUI interface onto the Blue Moon Rendering Tools (BMRT) command-line programs for previewing and rendering RenderMan .rib files on Windows and Linux/Unix machines. You can view and grab the complete script here: ribvu.pyw.
That particular script is a minimalist version of the more complex ribview.pyw script, which provides various preview and rendering options. (With the script running, click on the buttons labelled "normal," "bell," and "no stats" to get the options.)
Both scripts use the ".pyw" file extension, rather than the usual ".py," in order to suppress Python's DOS window on Windows machines. Leave it that way to avoid conflicts with the DOS windows used by BMRT. (Linux machines will run properly prepared .pyw scripts just like .py, but there probably isn't a similar windowing conflict.)
These scripts can be dropped right into the folder where your .rib files reside on a Linux/Unix or Windows machine that has both the Python 2+ scripting language and Blue Moon Rendering Tools for RenderMan installed (be prepared for big downloads).
For those who might venture to make changes in these scripts, understand that both have a user-set variable called usingIDLE which is normally set to =0. Set it to =1 (true) if you run these scripts from Python's IDLE script editor or any other Tkinter-based editor, but it must be set back to =0 (false) to run normally, such as by double-clicking in a file manager.
[_3DA#45 supplement_|_Learn Python_]
Learn Python
- Python & programming for non-programmers
- "Learning to Program" by Alan Gauld
- "Instant Hacking" (in the term's constructive sense) by Magnus Lie Hetland
- "Non-Programmers Tutorial For Python" [_HTML_|_PDF_] by Josh Cogliati
- "How to Think Like a Computer Scientist" (Python version) [_HTML_|_PDF_] by Allen Downey with Jeffrey Elkner
- Python for experienced programmers
Revised: 4 Aug 01 rev 0
http://www.3dartist.com/3dao/r/allenbil/python/index.html
© Copyright 2001 Columbine, Inc. - All Rights Reserved
Any mentioned trademarks are the property of their respective owners.