Cripts IN Lender: Author: N.tox
Cripts IN Lender: Author: N.tox
Author : N.tox
Version : 0.02
Summary
Summary:
1 Scripts types
2.1 PyConstraints
2.2 Linked scripts
2
Summary
1 Scripts types :
1.1 Classic Script :
The classic scripts are scripts written as regular self executeted python
scripts. To execute them, you must open a text window inBlender, and
open the script (as you would do with a text file), then you can execute
them by a Right Click and ‘Execute Script’ or by pressing Alt+P.
1.2 pydrivers :
Pydrivers are scripts which define functions and variables, they are used as
a module in python drivers expression command line. The functions defi-
ned in those scripts must be real functions, not routines, ie that the defined
functions must return values -integer or float, or at least those which will be
called from expression-, not only execute instructions. they must be named
pydrivers.py, and there only can be one pydrivers.py opened in a .blend
file.
Usage example :
1.3 pyConstraints :
PyConstraints are scripts used as constraint for script constraints :-p. They
can be really usefull because they are executed each frame and are better
managed than pyDrivers, except in version 2.4.5 where they didn’t exist yet
and where pydrivers are really better managed, this remark is avaible for
now (actual version 2.4.7), but maybe not in the future.
They need to be load in the text window buffer, ie in the text window (even
if not the displayed one). They don’t need a specific name but, they need to
have as first line, the following one :
#BPYCONSTRAINT
3
Summary
#!BPY
‘‘‘
Name: ‘Script Name Displayed in Blender’
Blender: 247
Group: ‘The parent group (category) of this script, like Wizards for exam-
ple case is still important’
Tooltip: ‘the short description displayed when mouse cursor will be over
the script name displayed’
‘‘‘
__author__ = ‘Your name ;p’
__url__ = (‘Your site‘)
__version__ = ‘Version of your script’
__bpydoc__ = ‘‘‘\
The «how to» of your script...
‘‘‘
#From her you can write your script like you usually do
4
Summary
We know that at each frame the script will be executed, but it is not really
true, I mean that in fact, precise expected functions (with expected name
so) are called, with always the same number (and types) of parameters. if
those functions are not present (or at least, the essentials one) the script
will not be considered as valid and nothing will happend.
doConstraint is the main function, ie the function which return the matrix
which will be applied to the constraint’s owner object. Only a 4x4 matrix
object (see Blender.Mathutils.Matrix docs) can be returned.
obmatrix :
target_matrices :
idprop :
5
Summary
target_object :
subtarget_bone :
target_matrix :
id_properties_of_constraint :
getSettings(idprop):
getSettings is the routine (ie do not return anything) which will be called
when the user click on the option button. this is here where we define
keys and values of idprop which is at the beginning a virgin dictionnary
(well, actually a blender IDPoperty object...). we define here too the UI
which will be displayed once this routine called. The two scripts I’ve seen
draw a PupBlock. I won’t explain you how to do, for it, see the Bpython
API docs ... I prefer show you an extract of one of the two script ana-
lysed (Constraint_Noise-1.0.py):
6
Summary
def getSettings(idprop):
# Define user-settable parameters.
# Must also be defined in getSettings().
if not idprop.has_key(‘u_loc’): idprop[‘u_loc’] = 1
if not idprop.has_key(‘u_rot’): idprop[‘u_rot’] = 0
if not idprop.has_key(‘u_scale’): idprop[‘u_scale’] = 0
if not idprop.has_key(‘u_locamount’): idprop[‘u_loca-
mount’] = 1.0
if not idprop.has_key(‘u_rotamount’): idprop[‘u_rota-
mount’] = 30.0
if not idprop.has_key(‘u_scaleamount’): idprop[‘u_sca-
leamount’] = 1.0
if not idprop.has_key(‘u_speed’): idprop[‘u_speed’] =
1.0
7
Summary
idprop[‘u_speed’]= uspeed.val
8
Summary
events :
‘FrameChanged’:
Each time a frame change, the script is execute before new positions
of objects -if animated- or at least bones, being actualize. So, if you
have many Python IPO Drivers to set, i encourage you to do the same
thing in an animation script rather than in a python driver. why ?
¤ a) because python drivers are quite weak, few manipulations
with action datablock often break them
¤ b) in an linked script you have a quick overview of all links, so it
is quickest to access them.
‘Redraw’:
Each time there is a Redraw Call (and this is far more often than a
FrameChanged), the animation script is called, I advise you to not link
to that event too much and/or too «heavy» scripts. A ptyhon transform
link (what the python drivers do...) placed here has some advantages
: the effects will be visible even when acting in 3D view, but it has a
price, if you’re not carefull or your scene has a lot of polygons, cons-
traints, calculations (etc...) to do, the display performances will dras-
tically decrease, and you will suffer several lag. That is why a good
management of layers can help, and if you’re a bit tricky, you can quite
simply create systems of dynamical script linking.
‘OnLoad’:
No comments
‘OnSave’:
No comments
‘Render’: