Home | Trees | Indices | Help |
|
---|
|
The Blender.Window submodule.
New: renamed ViewLayer to ViewLayers (actually added an alias, so both forms will work).
This module provides access to Window functions in Blender.
FileSelector:
import Blender from Blender import Window # def my_callback(filename): # callback for the FileSelector print "You chose the file:", filename # do something with the chosen file # Window.FileSelector (my_callback, "Choose one!")
DrawProgressBar:
import Blender from Blender.Window import DrawProgressBar # # substitute the bogus_*() function calls for your own, of course. # DrawProgressBar (0.0, "Importing data ...") bogus_importData() DrawProgressBar (0.3, "Building something") bogus_build() DrawProgressBar (0.8, "Updating Blender") bogus_update() DrawProgressBar (1.0, "Finished") # # another example: # number = 1 while number < 20: file = filename + "00%d" % number DrawProgressBar (number / 20.0, "Loading texture: %s" % file) Blender.Image.Load(file) number += 1 DrawProgressBar (1.0, "Finished loading")
Warning: The event system in Blender needs a rewrite, though we don't know when that will happen. Until then, event related functions here (QAdd, QRead, QHandle, etc.) can be used, but they are actually experimental and can be substituted for a better method when the rewrite happens. In other words, use them at your own risk, because though they should work well and allow many interesting and powerful possibilities, they can be deprecated in some future version of Blender / Blender Python.
Functions | |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
list of three floats |
|
||
int |
|
||
|
|||
|
|||
int |
|
||
|
|||
|
|||
list of three floats |
|
||
4x4 float matrix (WRAPPED DATA) |
|
||
4x4 float matrix (WRAPPED DATA) |
|
||
int (bool) |
|
||
|
|||
list of ints |
|
||
list of floats |
|
||
|
|||
list of floats |
|
||
|
|||
|
|||
int |
|
||
list |
|
||
|
|||
|
|||
bool |
|
||
list with two ints |
|
||
|
|||
int |
|
||
int |
|
||
int |
|
||
|
|||
list with two ints |
|
||
list with two ints |
|
||
list of strings |
|
||
|
|||
list of dictionaries |
|
Variables | |
readonly dictionary |
MButs Mouse buttons. |
readonly dictionary |
Qual Qualifier keys (shift, control, alt) bitmasks. |
readonly dictionary |
Types The available Window Types. |
__package__ = None
|
Function Details |
Force a redraw of a specific space type.
|
Open the file selector window in Blender. After the user selects a filename, it is passed as parameter to the function callback given to FileSelector(). Example: import Blender # def my_function(filename): print 'The selected file was:', filename # Blender.Window.FileSelector (my_function, 'SAVE FILE')
Warning: script links are not allowed to call the File / Image Selectors. This is because script links global dictionaries are removed when they finish execution and the File Selector needs the passed callback to stay around. An alternative is calling the File Selector from another script (see Blender.Run). |
Open the image selector window in Blender. After the user selects a filename, it is passed as parameter to the function callback given to ImageSelector(). Example: import Blender # def my_function(imagename): print 'The selected image was:', imagename # Blender.Window.ImageSelector (my_function, 'LOAD IMAGE')
Warning: script links are not allowed to call the File / Image Selectors. This is because script links global dictionaries are removed when they finish execution and the File Selector needs the passed callback to stay around. An alternative is calling the File Selector from another script (see Blender.Run). |
Draw a progress bar in the upper right corner of the screen. To cancel it prematurely, users can press the "Esc" key. Start it with done = 0 and end it with done = 1.
|
Get the current 3d cursor position.
|
Get the bitmask for the active layer.
Note: if there is no 3d view it will return zero. |
Set the bitmask for the active layer.
|
Change the 3d cursor position.
Note: if visible, the 3d View must be redrawn to display the change. This can be done with Redraw. |
Get the pivot for the active 3D view.
|
Set the pivot on the active 3D view.
|
Set cursor to wait or back to normal mode. Example: Blender.Window.WaitCursor(1) Blender.sys.sleep(2000) # do something that takes some time Blender.Window.WaitCursor(0) # back
Note: when the script finishes execution, the cursor is set to normal by Blender itself. |
Get the current 3d view vector.
|
Get the current 3d view matrix.
|
Get the current 3d perspective matrix.
|
Get and optionally set the current edit mode status: in or out. Example: in_editmode = Window.EditMode() # MUST leave edit mode before changing an active mesh: if in_editmode: Window.EditMode(0) # ... # make changes to the mesh # ... # be nice to the user and return things to how they were: if in_editmode: Window.EditMode(1)
Warning: this is an important function. NMesh operates on normal Blender meshes, not edit mode ones. If a script changes an active mesh while in edit mode, when the user leaves the mode the changes will be lost, because the normal mesh will be rebuilt based on its unchanged edit mesh. |
Get and optionally set the current pose mode status: in or out.
Warning: This uses the active armature objects posemode status, enabling pose mode for non armature objects will always fail. |
Get and optionally set the currently visible layers in all 3d Views.
|
Get the current VIEW3D view quaternion values.
|
Set the current VIEW3D view quaternion.
|
Get the current VIEW3D offset values.
Note: The 3 values returned are flipped in comparison object locations. |
Set the current VIEW3D offset values.
Note: The value you give flipped in comparison object locations. |
Set the current VIEW3D view to the active camera's view. If there's no active object or it is not of type 'Camera', the active camera for the current scene is used instead.
|
Check if there are pending events in the event queue.
|
Get the next pending event from the event queue. Example: # let's catch all events and move the 3D Cursor when user presses # the left mouse button. from Blender import Draw, Window v3d = Window.GetScreenInfo(Window.Types.VIEW3D) id = v3d[0]['id'] # get the (first) VIEW3D's id done = 0 while not done: # enter a 'get event' loop evt, val = Window.QRead() # catch next event if evt in [Draw.MOUSEX, Draw.MOUSEY]: continue # speeds things up, ignores mouse movement elif evt in [Draw.ESCKEY, Draw.QKEY]: done = 1 # end loop elif evt == Draw.SPACEKEY: Draw.PupMenu("Hey!|What did you expect?") elif evt == Draw.Redraw: # catch redraw events to handle them Window.RedrawAll() # redraw all areas elif evt == Draw.LEFTMOUSE: # left button pressed Window.QAdd(id, evt, 1) # add the caught mouse event to our v3d # actually we should check if the event happened inside that area, # using Window.GetMouseCoords() and v3d[0]['vertices'] values. Window.QHandle(id) # process the event # do something fancy like putting some object where the # user positioned the 3d cursor, then: Window.Redraw() # show the change in the VIEW3D areas.
|
Add an event to some window's (actually called areas in Blender) event queue.
|
Process immediately all pending events for the given window (area).
Note: see QAdd for how to send events to a particular window. |
Return true if the user has pressed escape
|
Get mouse's current screen coordinates.
|
Set mouse's current screen coordinates.
|
Get the current mouse button state (see / compare against MButs).
|
Get the current qualifier keys state (see / compare against Qual).
|
Fake qualifier keys state. This is useful because some key events require one or more qualifiers to be active (see QAdd).
Warning: remember to reset the qual keys to 0 once they are not necessary anymore. |
Get the current area's size.
Note: the returned values are 1 pixel bigger than what GetScreenInfo returns for the 'vertices' of the same area. |
Get Blender's screen size.
|
Get the names of all available screens.
|
Set as current screen the one with the given name.
|
Get info about the current screen setup.
|
Variables Details |
MButsMouse buttons.
|
QualQualifier keys (shift, control, alt) bitmasks.
|
TypesThe available Window Types.
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0 on Mon Aug 31 23:12:22 2009 | http://epydoc.sourceforge.net |