[Overview]
About:
blenpy=blenDER+pyTHON (Windows version)
blenpy provides an interface to script actions (edit, reference, run
and import) and to a variety of object browsers for Python in
Blender. It integrates existing Python development technologies
like Idle, PythonWin, PyCrust, Boa, Leo, ... in an extensible
framework. Besides it provides a (unfinished) module to ease the
creating of gui's for Python. As such this package is aimed at
Python developpers.
Contact: s_t_a_n_i@no-spam.yahoo.com
(c) www.stani.be 2003
.
Modules:
blenpy.pyGui: (blender python gui)
This user interface attempts to integrate as tight as possible existing
Python editing and introspection tools (Idle, ObjectBrowser,
PyCrust, PythonWin, Leo, SciTE...) in Blender. It targets people
with yet some Python experience. It aim is make developping
Python programs for Blender more easy. The screenshots might gave a
good impression. To fully profit from the benefits of this
package, the installation of wxPython is recommended. To use it
in any drawing, just type the following in a Blender Text window:
from blenpy.pyGui import PythonGui
PythonGui()
Always save your work first and to run it press Alt+P. For more
information read manual more down.
blenpy.gui: (blender gui)
A module to ease the making of gui's (graphical user interface) in
Blender, wrapping the most important functions from the Blender BGL and
Draw Modules. Features included:relative layout positioning, drawing
filled rectangles with optional borders and automated registration of
keyboard and button events. Supported are Buttons, Menus, Strings
and Texts, rest will follow later.
blPyGui was built upon blGui.
.
Requirements:
Blender 2.26+
Full python 2.22+
I recommend ActivePython distribution:
http://www.activestate.com/Products/ActivePython/index.html
Strongly recommended:
- PythonWin extensions (already included in ActivePython)
- wxpython (www.wxpython.org)
Optional:
- Boa Constructor
- Leo
- SciTE
- ...
.
Installation:(not valid at the moment)
Windows binary:
Double click the executable. After that, you'll get an icon group
in the Windows start menu. This has links to the help files, the
demo, uninstall and to all possible plugins on the internet. This
setup wizard was created with Inno Setup (www.innosetup.com) and ISTool
(www.istool.org). When you uninstall blenpy, the blenpy directory
will be removed. If you don't want to loose your settings in a
next version, than make a backup of the plugins directory.
Source:
Create a folder 'blenpy' in your Blender program path or any other
path, which is listed in the PYTHONPATH. Unzip there all the
files. Blenpy has only being tested under Windows. As it is
100% Python, it should be portable to Linux as well, although that
might involve some minor changes to the code. At the moment I
focus on the Windows version. However anybody with some Python
experience who wants to port it to Linux, may contact me.
.
Getting started:
Open demo.blend and press Alt+P in the text window. Above settings
you'll find a description of the current tool and in settings you can
change the mouse configuration. Important: before using the
blenpy gui, save your work. Sometimes blenpy might block Blender.
If you want to use the tools in another drawing type...
.
[blenpy.pyGui manual]
Tools:
Next to the launch button you can select a tool from the menu. If
you select a tool, the description will appear above. Before
launching the tool, make sure you have installed the required
modules. Tools which have (tk) depend on Tkinter and tools which
have (wx) on wxPython. You don't have to install Tkinter as it is
part of the standard Python distribution. If extra modules are
required, it is displayed in the description. If you have wxPython
installed, check out 'PyCrust >>>'. Press the launch
button to launch the Tool. When working with the tool, the
Blender application is not accessible (probably turns black). You
can only return to Blender by closing ALL the tool windows.
You can add your own tools by editing plugins\tools.py If this
tool could be interesting for other users, please send me than a
copy. So I can include it in the next release.
.
Browser:
In the mouse configuration: you can define actions for the mouse
buttons. There are now 3 types of actions:editing (see more
down), run and import. 'Run' executes the file and returns the
exitcode (see Blender console). 'Import' imports the file as if
it was a module. Reference is an interesting option if you want
to edit the script outside Blender. It doesn't import the source
code into Blender, but creates a Python shorcut script which will
execute the saved file on the disk when you press Alt+P.
The 'Select here...' button display a path menu. By the default
the current drawing directory is added as the 'working
directory'. To add a directory, press the 'b' button, which will
open a directory select dialog. Select the directory and press
'ok'. The directory is now added to the 'Select here'
menu. (If you don't have tkFileDialog installed on your
system, type the name in the field which contains '...'. Then
press the '+' button. The directory is than added.)
Before proceeding, remember the configuration of the mouse
actions. If you now select a path with the 'Select here...' menu,
a table with all python files of that path and all subpaths will be
displayed. By clicking above a file, the mouse action will be
triggered.
With the '-' button you can remove the active directory from the path
menu.
.
Editing:
Strategies:
1. 'Edit with ...': This provides an editor, from which programs
can be immediately run in Blender. It also provides a shell which
can be used to try out Python in Blender interactively. The Shell has
access to the Blender Namespace, which makes it possible to type
'import Blender' in the shell and than to use any Blender Python
command. PythonWin is without doubt the best solution with its
auto-indentation, calltips and auto-completion. Unfortunately it
can only be used once. So use Idle, if you want to switch
continously between Blender and the editing sessions.
2. 'Reference' & 'Send to ...': These two commands are very
usefull together. 'Reference' doesn't load the source code in a
Blender Text window, but places a short Python code to run the script
from the file. 'Send to ...' opens the file in an external
editor. So you can edit your file and save it. To try the
result immediately, just press Alt+P in Blender on the Python shortcut.
3. 'Load as Blender Text': The old way of using Python in Blender. It
loads the source as a Blender Text, adding a comment on the first line
'#@filename'. This comment is recognised by the 'Revert All' and
'Save All' buttons and will automatically load/save the source from/to
these files. The 'Save All' button won't save the first comment
line in the file on disk, so there is no need to remove it from
blender. To exclude a file from to the 'Revert All' and 'Save
All', just change '#@' in '#'. The 'Revert All' and 'Save
All' can be combined with external editing through 'Send to ...' but it
can be confusing to have the same file twice opened. It has the
risk of overwriting a new file with an old file.
The Blender Text window is a but 'unpythonic', as it doesn't support
auto-indentation, calltips or auto-completion. Its clipboard
operations (Cut Alt+X,Copy Alt+C and Paste Alt+V) are only working
within Blender and do not interact with other applications.
Therefore above strategies are preferable.
Extensibility:
You can add your own editors by editing plugins\editors.py for internal
and plugins\editors.txt for external editors. If this change
could be interesting for other users, please send me than a copy.
So I can include it in the next release.
.
Notations:
'>>>':
This means that the tool includes an object Browser with all objects in
the drawing, of which all 'get' methods are recursively evaluated (see
the '>>>' entries). In this way it is possible to see eg
of an [Object 'Camera'] automatically its data by '>>>
getData()', which could be [Camera 'Camera']. Although this can
be very usefull, it can be too clumbersome for bigger drawings.
So it is better to limit its use to light drawings.
'Light':
This means that the tool doesn't preload the Blender module and its
object browser.
.
Customizing:
Power users can customize files like mouse.py, tools.py and editors.txt
in the plugins folder. If you do, please if you changed these
files please send me a copy, so it can be updated for the next release
and all users can profit from it.
.
[Appendix]
Files:
gui General module for creating
gui's
pyGui User interface for Python
devellopers
doc\ Documentation
...
plugins\ You can edit these to add
other editors or tools:
editors.txt External editors (Send to)
editors.py Internal editors (Edit)
mouse.py Mouse button actions (such as run,
import,...)
tools.py Tools
sm\ Blender independent modules
tk* Tkinter specific
wxp* wxPython specific
Todo:
- Better documentation
- Finish the gui module
- ...
Known issues:
- Boa Constructor: can only run if you disable all Zope features.
- pydoc: This will crash Blender. Don't use it, unless you know
what you are doing.
- PythonWin: Edit only works once within one Blender session.
Bugs in the Blender API:
One of these errors might appear in the Blender console, but you can
safely ignore them:
Internal error, Invalid prop entry
Trying to access the attribute 'starColNoise' of the World class gives
this error statement.
ipo member access deprecated,use self.getIpo() instead!
Trying to access the attribute ipo gives this error statement.