Exppython docs:

- Updates and fixes to the documentation files, only, no code involved.
This commit is contained in:
2003-07-22 00:27:03 +00:00
parent 9a5cf3cb66
commit de60889865
12 changed files with 170 additions and 139 deletions

View File

@@ -20,46 +20,45 @@ OpenGL}" and the online NeHe tutorials are two of the best resources.
@see: U{www.opengl.org}
Example::
import Blender
from Blender.BGL import *
from Blender import Draw
R = G = B = 0
A = 1
instructions = "Hold mouse buttons to change the background color."
quitting = " Press ESC or q to quit."
#
def show_win():
glClearColor(R,G,B,A) # define color used to clear buffers
glClear(GL_COLOR_BUFFER_BIT) # use it to clear the color buffer
glColor3f(1,1,1) # change default color
glRasterPos2i(50,100) # move cursor to x = 50, y = 100
Draw.Text("Testing BGL + Draw") # draw this text there
glRasterPos2i(350,20) # move cursor again
Draw.Text(instructions + quitting) # draw another msg
glBegin(GL_LINE_LOOP) # begin a vertex-data list
glVertex2i(46,92)
glVertex2i(120,92)
glVertex2i(120,115)
glVertex2i(46,115)
glEnd() # close this list
glColor3f(0.35,0.18,0.92) # change default color again
glBegin(GL_POLYGON) # another list, for a polygon
glVertex2i(315, 292)
glVertex2i(412, 200)
glVertex2i(264, 256)
glEnd()
Draw.Redraw(1) # make changes visible.
#
def ev(evt, val): # this is a callback for Draw.Register()
global R,G,B,A # ... it handles input events
if evt == Draw.ESCKEY or evt == Draw.QKEY:
Draw.Exit() # this quits the script
elif evt == Draw.LEFTMOUSE: R = 1 - R
elif evt == Draw.MIDDLEMOUSE: G = 1 - G
elif evt == Draw.RIGHTMOUSE: B = 1 - B
else:
Draw.Register(show_win, ev, None)
#
Draw.Register(show_win, ev, None) # start the main loop
import Blender
from Blender.BGL import *
from Blender import Draw
R = G = B = 0
A = 1
instructions = "Hold mouse buttons to change the background color."
quitting = " Press ESC or q to quit."
#
def show_win():
glClearColor(R,G,B,A) # define color used to clear buffers
glClear(GL_COLOR_BUFFER_BIT) # use it to clear the color buffer
glColor3f(1,1,1) # change default color
glRasterPos2i(50,100) # move cursor to x = 50, y = 100
Draw.Text("Testing BGL + Draw") # draw this text there
glRasterPos2i(350,20) # move cursor again
Draw.Text(instructions + quitting) # draw another msg
glBegin(GL_LINE_LOOP) # begin a vertex-data list
glVertex2i(46,92)
glVertex2i(120,92)
glVertex2i(120,115)
glVertex2i(46,115)
glEnd() # close this list
glColor3f(0.35,0.18,0.92) # change default color again
glBegin(GL_POLYGON) # another list, for a polygon
glVertex2i(315, 292)
glVertex2i(412, 200)
glVertex2i(264, 256)
glEnd()
Draw.Redraw(1) # make changes visible.
#
def ev(evt, val): # this is a callback for Draw.Register()
global R,G,B,A # ... it handles input events
if evt == Draw.ESCKEY or evt == Draw.QKEY:
Draw.Exit() # this quits the script
elif evt == Draw.LEFTMOUSE: R = 1 - R
elif evt == Draw.MIDDLEMOUSE: G = 1 - G
elif evt == Draw.RIGHTMOUSE: B = 1 - B
else:
Draw.Register(show_win, ev, None)
#
Draw.Register(show_win, ev, None) # start the main loop
"""

View File

@@ -99,4 +99,6 @@ def ReleaseGlobalDict (bool = None):
behavior.
@rtype: int
@return: A bool value (0 or 1) telling the current behavior.
@warn: This function was added as a test and there's a good chance that it
won't be kept in the future, in favor of a better method.
"""

View File

@@ -9,13 +9,12 @@ Curve Data
This module provides access to B{Curve Data} objects in Blender.
Example::
from Blender import Curve, Object, Scene
c = Curve.New(). # create new curve data
cur = Scene.getCurrent(). # get current scene
ob = Object.New('Curve'). # make curve object
ob.link(c). # link curve data with this object
cur.link(ob). # link object into scene
c = Curve.New() # create new curve data
cur = Scene.getCurrent() # get current scene
ob = Object.New('Curve') # make curve object
ob.link(c) # link curve data with this object
cur.link(ob) # link object into scene
"""
def New ( name = 'CurData'):

View File

@@ -12,63 +12,64 @@ scrollbar, plus support for text drawing. It also includes keyboard keys and
mouse button code values in its dictionary (print dir(Blender.Draw)).
Example::
import Blender
from Blender import Draw, BGL
#
mystring = ""
mymsg = ""
toggle = 0
#
def event(evt, val): # the function to handle input events
global mystring, mymsg
import Blender
from Blender import Draw, BGL
#
mystring = ""
mymsg = ""
toggle = 0
#
def event(evt, val): # the function to handle input events
global mystring, mymsg
if not val: # val = 0: it's a key/mbutton release
if evt in [Draw.LEFTMOUSE, Draw.MIDDLEMOUSE, Draw.RIGHTMOUSE]:
mymsg = "You released a mouse button."
Draw.Redraw(1)
return
if not val: # val = 0: it's a key/mbutton release
if evt in [Draw.LEFTMOUSE, Draw.MIDDLEMOUSE, Draw.RIGHTMOUSE]:
mymsg = "You released a mouse button."
Draw.Redraw(1)
return
if evt == Draw.ESCKEY:
Draw.Exit() # exit when user presses ESC
return
if evt == Draw.ESCKEY:
Draw.Exit() # exit when user presses ESC
return
elif Draw.AKEY <= evt <= Draw.ZKEY: mystring += chr(evt)
elif evt == Draw.SPACEKEY: mystring += ' '
elif evt == Draw.BACKSPACEKEY and len(mystring):
mystring = mystring[:-1]
else: return # this is important: only re-register if an event was caught
elif Draw.AKEY <= evt <= Draw.ZKEY: mystring += chr(evt)
elif evt == Draw.SPACEKEY: mystring += ' '
elif evt == Draw.BACKSPACEKEY and len(mystring):
mystring = mystring[:-1]
else: return # this is important: only re-register if an event was caught
Draw.Register(gui, event, button_event) # re-register to stay in the loop
#
def button_event(evt): # the function to handle Draw Button events
global mymsg, toggle
if evt == 1:
mymsg = "You pressed the toggle button."
toggle = 1 - toggle
Draw.Redraw(1)
else:
Draw.Register(gui, event, button_event)
#
def gui(): # the function to draw the screen
global mystring, mymsg, toggle
if len(mystring) > 90: mystring = ""
BGL.glClearColor(0,0,1,1)
BGL.glClear(BGL.GL_COLOR_BUFFER_BIT)
BGL.glColor3f(1,1,1)
Draw.Toggle("Toggle", 1, 10, 10, 55, 20, toggle,"A toggle button")
BGL.glRasterPos2i(72, 16)
if toggle: toggle_state = "down"
else: toggle_state = "up"
Draw.Text("The toggle button is %s." % toggle_state, "small")
BGL.glRasterPos2i(10, 230)
Draw.Text("Type letters from a to z, ESC to leave.")
BGL.glRasterPos2i(20, 200)
Draw.Text(mystring)
BGL.glColor3f(1,0.4,0.3)
BGL.glRasterPos2i(340, 70)
Draw.Text(mymsg, "tiny")
#
Draw.Register(gui, event, button_event) # registering the 3 callbacks
Draw.Register(gui, event, button_event) # re-register to stay in the loop
#
def button_event(evt): # the function to handle Draw Button events
global mymsg, toggle
if evt == 1:
mymsg = "You pressed the toggle button."
toggle = 1 - toggle
Draw.Redraw(1)
else:
Draw.Register(gui, event, button_event)
#
def gui(): # the function to draw the screen
global mystring, mymsg, toggle
if len(mystring) > 90: mystring = ""
BGL.glClearColor(0,0,1,1)
BGL.glClear(BGL.GL_COLOR_BUFFER_BIT)
BGL.glColor3f(1,1,1)
Draw.Toggle("Toggle", 1, 10, 10, 55, 20, toggle,"A toggle button")
BGL.glRasterPos2i(72, 16)
if toggle: toggle_state = "down"
else: toggle_state = "up"
Draw.Text("The toggle button is %s." % toggle_state, "small")
BGL.glRasterPos2i(10, 230)
Draw.Text("Type letters from a to z, ESC to leave.")
BGL.glRasterPos2i(20, 200)
Draw.Text(mystring)
BGL.glColor3f(1,0.4,0.3)
BGL.glRasterPos2i(340, 70)
Draw.Text(mymsg, "tiny")
#
Draw.Register(gui, event, button_event) # registering the 3 callbacks
@warn: Inside the windowing loop (after Draw.Register() has been executed and
before Draw.Exit() is called), don't use the redraw functions from other
modules (Blender and Window). The Draw submodule has its own Draw.Redraw() and

View File

@@ -19,8 +19,8 @@ effect, which can be a wave, particle or build effect. The python API follows
this structure : the Effect module grants access to (the few) data which
are shared between all effects. It has three submodules : Wave, Build, Particle
, which grant r/w access to the real parameters of these effects.
Example::
Example::
import Blender
"""

View File

@@ -7,13 +7,12 @@ This module provides access to the Ipo Data in Blender.
Example::
import Blender
ob = Blender.Ipo.Get('ipo') # retreives an ipo object
ob.setName('ipo1')
print ob.name
print ipo.getRctf()
ipo.setRctf(1,2,3,4)
ob.setName('ipo1')
print ob.name
print ipo.getRctf()
ipo.setRctf(1,2,3,4)
"""

View File

@@ -6,10 +6,9 @@ The Blender.Metaball submodule
This module provides access to the B{Metaball Data} in Blender.
Example::
import Blender
scene = Blencer.Scene.getCurrent () # get the current scene
ob = Blender.Metaball.New ('mball') # make metaball
scene = Blender.Scene.getCurrent () # get the current scene
ob = Blender.Metaball.New ('mball') # make metaball
"""
def New (name):

View File

@@ -280,6 +280,12 @@ class NMesh :
@type frame: int
@param frame: The Scene frame where the mesh key should be inserted. If
None, the current frame is used.
@warn: This and L{removeAllKeys} were included in this release only to
make accessing vertex keys possible, but are not a proper solution.
For example, it seems that 'frame' should be kept in the range [1, 100]
(the curves can be manually tweaked in the Ipo Curve Editor window in
Blender itself later). In the future a complete Key module should be
created.
"""
def removeAllKeys():

View File

@@ -9,7 +9,19 @@ Scene
This module provides access to B{Scenes} in Blender.
Example::
import Blender
from Blender import Scene, Object, Camera
#
camdata = Camera.New('ortho') # create new camera data
camdata.setName('newCam')
camdata.setLens(16.0)
camobj = Object.New('Camera') # create a new camera object
camobj.link(camdata) # link data to object
scene = Scene.New('NewScene') # create a new scene
scene.link(camobj) # link object to scene
scene.frameSettings(1, 100 ,1) # set start, end and current frames
scene.setWinSize(640, 480) # set the render window dimensions
scene.makeCurrent() # make this the current scene
"""
def New (name = 'Scene'):
@@ -71,7 +83,7 @@ class Scene:
"""
Get the current x,y resolution of the render window. These are the
dimensions of the image created by the Blender Renderer.
@rtype: list
@rtype: list of two ints
@return: [width, height].
"""
@@ -79,7 +91,7 @@ class Scene:
"""
Set the width and height of the render window. These are the dimensions
of the image created by the Blender Renderer.
@type dimensions: list
@type dimensions: list of two ints
@param dimensions: The new [width, height] values.
"""

View File

@@ -7,24 +7,23 @@ The Blender.Types submodule
This module is a dictionary of Blender Python types, for type checking.
Example::
import Blender
from Blender import Types, Object, NMesh, Camera, Lamp
#
objs = Object.Get() # a list of all objects in the current scene
for o in objs:
print
print o, type(o)
data = o.getData()
print type(data)
if type(data) == Types.NMeshType:
if len(data.verts):
print "its vertices are obviously of type:", type(data.verts[0])
print "and its faces:", Types.NMFaceType
elif type(data) == Types.CameraType:
print "It's a Camera."
elif type(data) == Types.LampType:
print "Let there be light!"
import Blender
from Blender import Types, Object, NMesh, Camera, Lamp
#
objs = Object.Get() # a list of all objects in the current scene
for o in objs:
print
print o, type(o)
data = o.getData()
print type(data)
if type(data) == Types.NMeshType:
if len(data.verts):
print "its vertices are obviously of type:", type(data.verts[0])
print "and its faces:", Types.NMFaceType
elif type(data) == Types.CameraType:
print "It's a Camera."
elif type(data) == Types.LampType:
print "Let there be light!"
@var ObjectType: Blender Object. The base object, linked to its specific data
at its .data member variable.

View File

@@ -50,11 +50,27 @@ DrawProgressBar::
DrawProgressBar (1.0, "Finished loading")
@type Types: readonly dictionary
@var Types: The available Window Types.
- VIEW3D
- IPO
- OOPS
- BUTS
- FILE
- IMAGE
- INFO
- SEQ
- IMASEL
- SOUND
- ACTION
- TEXT
- NLA
"""
def Redraw ():
"""
Force a redraw of a specific Window Type (see Window.Types).
Force a redraw of a specific Window Type (see L{Types}).
"""
def RedrawAll ():

View File

@@ -5,15 +5,14 @@ The Blender.World submodule
INTRODUCTION
The module world allows you to access all the data of an world.
Example::
The module world allows you to access all the data of a Blender World.
Example::
import Blender
w = Blender.Get('World') #assume there exists a world named "world"
print w.GetName()
w.hor = [1,1,.2]
print w.Gethor()
w = Blender.Get('World') #assume there exists a world named "world"
print w.getName()
w.hor = [1,1,.2]
print w.getHor()
"""
def New (name):