Scripts: - Thanks Jean-Michel Soler (jms) for updated versions of dispaint, fixfromarmature and unweld (also renamed to remove version part). - Thanks Bart for the upgraded VRML exporter (great doc webpage!). It is available as VRML 97 and the original VRML 2 is for now still there, to help users testing the new version. For the next release the old one should be removed, of course. - New script: Scripts Config Editor (Scripts win -> Scripts -> System). Scripts with config options (simple data that is to be set according to user needs or preferences) can use this facility instead of providing a gui and writing config files to disk themselves. - Added new menu: System, available in the Scripts win. - Updated sys_info.py, help_browse.py and the AC3D importer and exporter. - Removed use of the Scrollbar and added arrow keys and mouse wheel support instead in Daniel Dunbar's old doc_browser.py. The scrollbar events handling doesn't exist, Ton suggested removing the scrollbar from the API months ago. For now its ref doc is gone and no bundled script uses it, until we get time to implement it properly. - Added module BPyRegistry.py with functions to handle reading / writing config files automatically to the scripts/bpydata/config dir. - Removing dir release/bpydata and its contents (moved earlier to release/scripts/bpydata/) - Bug #2379: made small changes to bevel_center's ui to fix a problem reported by Alexander Ewering (intrr): http://projects.blender.org/tracker/?func=detail&atid=125&aid=2379&group_id=9 BPython: - Thanks Campbell Barton for new functionality: Blender.Get() now can also return all the paths from the user prefs -> file paths win and there is a new function: Blender.sys.expandpath() to transform Blender paths (those starting with '//' and ending with '#') to absolute paths. - Added function Blender.ShowHelp(), to open the Scripts Help Browser with a given help page -- just a time saver for scripts. - Improved function Blender.Run() to also work with gui and file select scripts. - Found a (new?) crash related to NMesh.PutRaw when creating a new object while in edit mode. Leaving / entering edit mode fixes the problem, so a check for obj created, edit mode and leaving / re-entering it were added to the code for now (gdb didn't help much, no backtrace) - doc updates, including splitting intro page in two, with bpython related stuff (registering / documenting / configuring scripts and command line mode (thanks Chris Want for "use system variables to pass parameters to scripts" idea). - Registry: functions have been updated to support writing to / reading from disk, for the config editor -- only simple config data supported, for large amounts coders should write to a file themselves. This is done with a new parameter: Registry.GetKey(keyname, True) will also search for the key on the config dir, if not already loaded; equiv. for Registry.SetKey(keyname, dict, True). Data is only written to / read from disk when needed and only scripts already used (assuming they support this functionality) will have config data saved.
191 lines
7.7 KiB
Python
191 lines
7.7 KiB
Python
# The Blender Module
|
|
|
|
# The module files in this folder are used to create the API documentation.
|
|
# Doc system used: epydoc - http://epydoc.sf.net
|
|
# pseudo command line (check the epy_docgen.sh file):
|
|
# epydoc -o BPY_API_23x --url "http://www.blender.org" -t Blender.py \
|
|
# -n "Blender" --no-private --no-frames Blender.py \
|
|
# Types.py Scene.py Object.py [ ... etc]
|
|
|
|
"""
|
|
The main Blender module.
|
|
|
|
B{New}: L{Run}, L{UpdateMenus}, new options to L{Get}, L{ShowHelp}.
|
|
|
|
Blender
|
|
=======
|
|
|
|
@type bylink: bool
|
|
@var bylink: True if the current script is being executed as a script link.
|
|
@type link: Blender Object or None
|
|
@var link: if this script is a running script link, 'link' points to the
|
|
linked Object (can be a scene, object (mesh, camera, lamp), material or
|
|
world). If this is not a script link, 'link' is None.
|
|
@type event: string
|
|
@var event: if this script is a running script link, 'event' tells what
|
|
kind of link triggered it (ex: OnLoad, FrameChanged, Redraw, etc.).
|
|
@type mode: string
|
|
@var mode: Blender's current mode:
|
|
- 'interactive': normal mode, with an open window answering to user input;
|
|
- 'background': Blender was started as 'C{blender -b <blender file>}' and
|
|
will exit as soon as it finishes rendering or executing a script
|
|
(ex: 'C{blender -b <blender file> -P <script>}'). Try 'C{blender -h}'
|
|
for more detailed informations.
|
|
"""
|
|
|
|
def Set (request, data):
|
|
"""
|
|
Update settings in Blender.
|
|
@type request: string
|
|
@param request: The setting to change:
|
|
- 'curframe': the current animation frame
|
|
@type data: int
|
|
@param data: The new value.
|
|
"""
|
|
|
|
def Get (request):
|
|
"""
|
|
Retrieve settings from Blender.
|
|
@type request: string
|
|
@param request: The setting data to be returned:
|
|
- 'curframe': the current animation frame.
|
|
- 'curtime' : the current animation time.
|
|
- 'staframe': the start frame of the animation.
|
|
- 'endframe': the end frame of the animation.
|
|
- 'filename': the name of the last file read or written.
|
|
- 'homedir': Blender's home dir.
|
|
- 'datadir' : the path to the dir where scripts should store and
|
|
retrieve their data files, including saved configuration (can
|
|
be None, if not found).
|
|
- 'udatadir': the path to the user defined data dir. This may not be
|
|
available (is None if not found), but users that define uscriptsdir
|
|
have a place for their own scripts and script data that won't be
|
|
erased when a new version of Blender is installed.
|
|
- 'scriptsdir': the path to the main dir where scripts are stored.
|
|
- 'uscriptsdir': the path to the user defined dir for scripts. (*)
|
|
- 'yfexportdir': the path to the user defined dir for yafray export. (*)
|
|
- 'fontsdir': the path to the user defined dir for fonts. (*)
|
|
- 'texturesdir': the path to the user defined dir for textures. (*)
|
|
- 'texpluginsdir': the path to the user defined dir for texture plugins. (*)
|
|
- 'seqpluginsdir': the path to the user defined dir for sequence plugins. (*)
|
|
- 'renderdir': the path to the user defined dir for render output. (*)
|
|
- 'soundsdir': the path to the user defined dir for sound files. (*)
|
|
- 'tempdir': the path to the user defined dir for storage of Blender
|
|
temporary files. (*)
|
|
- 'version' : the Blender version number.
|
|
@note: (*) these can be set in Blender at the User Preferences window -> File
|
|
Paths tab.
|
|
@warn: this function returns None for requested dir paths that have not been
|
|
set or do not exist in the user's file system.
|
|
@return: The requested data or None if not found.
|
|
"""
|
|
|
|
def Redraw ():
|
|
"""
|
|
Redraw all 3D windows.
|
|
"""
|
|
|
|
def Load (filename = None):
|
|
"""
|
|
Load a Blender .blend file or any of the other supported file formats.
|
|
|
|
Supported formats:
|
|
- Blender's .blend;
|
|
- DXF;
|
|
- Open Inventor 1.0 ASCII;
|
|
- Radiogour;
|
|
- STL;
|
|
- Videoscape;
|
|
- VRML 1.0 asc.
|
|
|
|
@type filename: string
|
|
@param filename: the pathname to the desired file. If 'filename'
|
|
isn't given or if it contains the substring '.B.blend', the default
|
|
.B.blend file is loaded.
|
|
|
|
@warn: loading a new .blend file removes the current data in Blender. For
|
|
safety, this function saves the current data as an autosave file in
|
|
the temporary dir used by Blender before loading a new Blender file.
|
|
@warn: after a call to Load(blendfile), current data in Blender is lost,
|
|
including the Python dictionaries. Any posterior references in the
|
|
script to previously defined data will generate a NameError. So it's
|
|
better to put Blender.Load as the last executed command in the script,
|
|
when this function is used to open .blend files.
|
|
@warn: if in edit mode, this function leaves it, since Blender itself
|
|
requires that.
|
|
"""
|
|
|
|
def Save (filename, overwrite = 0):
|
|
"""
|
|
Save a Blender .blend file with the current program data or export to
|
|
one of the builtin file formats.
|
|
|
|
Supported formats:
|
|
- Blender (.blend);
|
|
- DXF (.dxf);
|
|
- STL (.stl);
|
|
- Videoscape (.obj);
|
|
- VRML 1.0 (.wrl).
|
|
|
|
@type filename: string
|
|
@param filename: the filename for the file to be written. It must have one
|
|
of the supported extensions or an error will be returned.
|
|
@type overwrite: int (bool)
|
|
@param overwrite: if non-zero, file 'filename' will be overwritten if it
|
|
already exists (can be checked with L{Blender.sys.exists<Sys.exists>}.
|
|
By default existing files are not overwritten (an error is returned).
|
|
|
|
@note: The substring ".B.blend" is not accepted inside 'filename'.
|
|
@note: DXF, STL and Videoscape export only B{selected} meshes.
|
|
"""
|
|
|
|
def Run (script):
|
|
"""
|
|
Execute the given script.
|
|
@type script: string
|
|
@param script: the name of an available Blender Text (use L{Text.Get}() to
|
|
get a complete list) or the full pathname to a Python script file in the
|
|
system.
|
|
@note: the script is executed in its own context -- with its own global
|
|
dictionary -- as if it had been executed from the Text Editor or chosen
|
|
from a menu.
|
|
"""
|
|
|
|
def ShowHelp (script):
|
|
"""
|
|
Show help for the given script. This is a time-saver ("code-saver") for
|
|
scripts that need to feature a 'help' button in their GUI's or a 'help'
|
|
submenu option. With proper documentation strings, calling this function is
|
|
enough to present a screen with help information plus link and email buttons.
|
|
@type script: string
|
|
@param script: the filename of a registered Python script.
|
|
@note: this function uses L{Run} and the "Scripts Help Browser" script. This
|
|
means that it expects proper doc strings in the script to be able to show
|
|
help for it (otherwise it offers to load the script source code as text).
|
|
The necessary information about doc strings is in the
|
|
L{Intro page<API_intro>} of this API Reference documentation you're
|
|
reading.
|
|
@note: 'script' doesn't need to be a full path name: "filename.py" is enough.
|
|
Note, though, that this function only works for properly registered
|
|
scripts (those that appear in menus).
|
|
"""
|
|
|
|
def UpdateMenus ():
|
|
"""
|
|
Update the menus that list registered scripts. This will scan the default
|
|
and user defined (if available) folder(s) for scripts that have registration
|
|
data and will make them accessible via menus.
|
|
@note: only scripts that save other new scripts in the default or user
|
|
defined folders need to call this function.
|
|
"""
|
|
|
|
def Quit ():
|
|
"""
|
|
Exit from Blender immediately.
|
|
@warn: the use of this function should obviously be avoided, it is available
|
|
because there are some cases where it can be useful, like in automated
|
|
tests. For safety, a "quit.blend" file is saved (normal Blender behavior
|
|
upon exiting) when this function is called, so the data in Blender isn't
|
|
lost.
|
|
"""
|