Module Constraint
[hide private]
[frames] | no frames]

Source Code for Module Constraint

  1  # Blender.Constraint module and the Constraint PyType object 
  2   
  3  """ 
  4  The Blender.Constraint submodule 
  5   
  6  B{New}: 
  7          -  provides access to Blender's constraint stack 
  8   
  9  This module provides access to the Constraint Data in Blender. 
 10   
 11  Examples:: 
 12          from Blender import * 
 13   
 14          ob = Object.Get('Cube') 
 15          if len(ob.constraints) > 0: 
 16                  const = ob.constraints[0] 
 17                  if const.type == Constraint.Type.FLOOR: 
 18                          offs = const[Constraint.Settings.OFFSET] 
 19           
 20  Or to print all the constraints attached to each bone in a pose:: 
 21          from Blender import * 
 22           
 23          ob = Object.Get('Armature') 
 24          pose = ob.getPose() 
 25          for bonename in pose.bones.keys(): 
 26                  bone = pose.bones[bonename] 
 27                  for const in bone.constraints: 
 28                          print bone.name,'=>',const 
 29   
 30  @type Type: readonly dictionary 
 31  @var Type: Constant Constraint dict used by L{Constraints.append()} and  
 32          for comparison with L{Constraint.type}.  Values are 
 33          TRACKTO, IKSOLVER, FOLLOWPATH, COPYROT, COPYLOC, COPYSIZE, ACTION, 
 34          LOCKTRACK, STRETCHTO, FLOOR, LIMITLOC, LIMITROT, LIMITSIZE, LIMITDIST,  
 35          CLAMPTO, PYTHON, CHILDOF, TRANSFORM, NULL 
 36   
 37  @type Settings: readonly dictionary 
 38  @var Settings: Constant dict used for changing constraint settings. 
 39          - Used for all single-target constraints  
 40                  (TRACKTO, FOLLOWPATH, COPYROT, COPYLOC, COPYSIZE, ACTION, LOCKTRACK, STRETCHTO, FLOOR, CLAMPTO, CHILDOF, TRANSFORM, LIMITDIST) 
 41          - TARGET (Object): target object 
 42          - BONE (string): name of Bone sub-target (for Armature targets), or name of Vertex Group sub-target 
 43                          (for Geometry targets) 
 44          - Used for all multiple-target constraints (PYTHON) 
 45                  - TARGET (list of Objects): list of target objects, with one list slot = one target slot 
 46                  - BONE (list of strings): list of names of Bone sub-target (for Armature targets) or name of Vertex Group 
 47                          sub-targets (for Geometry targets) 
 48          - Used by some constraints: 
 49                  - OWNERSPACE (int): for TRACKTO, COPYLOC, COPYROT, COPYSIZE, LIMITLOC, LIMITROT, LIMITSIZE, PYTHON, TRANSFORM 
 50                          If the owner is an object, values are SPACE_WORLD, SPACE_LOCAL 
 51                          If the owner is a bone, values are SPACE_WORLD, SPACE_POSE, SPACE_PARLOCAL, SPACE_LOCAL 
 52                  - TARGETSPACE (list of ints): for TRACKTO, COPYLOC, COPYROT, COPYSIZE, PYTHON, TRANSFORM, ACTION 
 53                          For every target that the Constraint can have, the target space can be set 
 54                          If the target is an object, values are SPACE_WORLD, SPACE_LOCAL 
 55                          If the target is a bone, values are SPACE_WORLD, SPACE_POSE, SPACE_PARLOCAL, SPACE_LOCAL 
 56          - Used by IK Solver (IKSOLVER) constraint: 
 57                  - TOLERANCE (float): clamped to [0.0001:1.0] 
 58                  - ITERATIONS (int): clamped to [1,10000] 
 59                  - CHAINLEN (int): clamped to [0,255] 
 60                  - POSWEIGHT (float): clamped to [0.01,1.0] 
 61                  - ROTWEIGHT (float): clamped to [0.01,1.0] 
 62                  - ROTATE (bool) 
 63                  - USETIP (bool) 
 64          - Used by Action (ACTION) constraint: 
 65                  - ACTION (Action Object) 
 66                  - START (int): clamped to [1,maxframe] 
 67                  - END (int): clamped to [1,maxframe] 
 68                  - MIN (float): clamped to [-1000.0,1000.0] for Location, [-180.0,180.0] for Rotation, [0.0001,1000.0] for Scaling 
 69                  - MAX (float): clamped to [-1000.0,1000.0] for Location, [-180.0,180.0] for Rotation, [0.0001,1000.0] for Scaling 
 70                  - KEYON (int): values are XLOC, YLOC, ZLOC, XROT, YROT, ZROT, XSIZE, YSIZE, ZSIZE 
 71          - Used by Track To (TRACKTO) constraint: 
 72                  - TRACK (int): values are TRACKX, TRACKY, TRACKZ, TRACKNEGX, 
 73                          TRACKNEGY, TRACKNEGZ 
 74                  - UP (int): values are UPX, UPY, UPZ 
 75          - Used by Stretch To (STRETCHTO) constraint: 
 76                  - RESTLENGTH (float): clamped to [0.0:100.0] 
 77                  - VOLVARIATION (float): clamped to [0.0:100.0] 
 78                  - VOLUMEMODE (int): values are VOLUMEXZ, VOLUMEX, VOLUMEZ, 
 79                          VOLUMENONE 
 80                  - PLANE (int): values are PLANEX, PLANEZ 
 81          - Used by Follow Path (FOLLOWPATH) constraint: 
 82                  - FOLLOW (bool) 
 83                  - OFFSET (float): clamped to [-maxframe:maxframe] 
 84                  - FORWARD (int): values are TRACKX, TRACKY, TRACKZ, TRACKNEGX, 
 85                          TRACKNEGY, TRACKNEGZ 
 86                  - UP (int): values are UPX, UPY, UPZ 
 87          - Used by Lock Track (FOLLOWPATH) constraint: 
 88                  - TRACK (int): values are TRACKX, TRACKY, TRACKZ, TRACKNEGX, 
 89                          TRACKNEGY, TRACKNEGZ 
 90                  - LOCK (int): values are LOCKX, LOCKY, LOCKZ 
 91          - Used by Clamp To (CLAMPTO) constraint: 
 92                  - CLAMP (int): values are CLAMPAUTO, CLAMPX, CLAMPY, CLAMPZ 
 93                  - CLAMPCYCLIC (bool) 
 94          - Used by Floor (FLOOR) constraint: 
 95                  - MINMAX (int): values are MINX, MINY, MINZ, MAXX, MAXY, MAXZ 
 96                  - OFFSET (float): clamped to [-100.0,100.0] 
 97                  - STICKY (bool) 
 98          - Used by Copy Location (COPYLOC) and Copy Rotation (COPYROT) 
 99                  - COPY (bitfield): any combination of COPYX, COPYY and COPYZ with possible addition of COPYXINVERT, COPYYINVERT and COPYZINVERT to invert that particular input (if on). 
100          - Used by Copy Size (COPYSIZE) constraint: 
101                  - COPY (bitfield): any combination of COPYX, COPYY and COPYZ 
102          - Used by Limit Location (LIMITLOC) constraint: 
103                  - LIMIT (bitfield): any combination of LIMIT_XMIN, LIMIT_XMAX, 
104                          LIMIT_YMIN, LIMIT_YMAX, LIMIT_ZMIN, LIMIT_ZMAX 
105                  - XMIN (float): clamped to [-1000.0,1000.0] 
106                  - XMAX (float): clamped to [-1000.0,1000.0] 
107                  - YMIN (float): clamped to [-1000.0,1000.0] 
108                  - YMAX (float): clamped to [-1000.0,1000.0] 
109                  - ZMIN (float): clamped to [-1000.0,1000.0] 
110                  - ZMAX (float): clamped to [-1000.0,1000.0] 
111          - Used by Limit Rotation (LIMITROT) constraint: 
112                  - LIMIT (bitfield): any combination of LIMIT_XROT, LIMIT_YROT,  
113                          LIMIT_ZROT 
114                  - XMIN (float): clamped to [-360.0,360.0] 
115                  - XMAX (float): clamped to [-360.0,360.0] 
116                  - YMIN (float): clamped to [-360.0,360.0] 
117                  - YMAX (float): clamped to [-360.0,360.0] 
118                  - ZMIN (float): clamped to [-360.0,360.0] 
119                  - ZMAX (float): clamped to [-360.0,360.0] 
120          - Used by Limit Scale (LIMITSIZE) constraint: 
121                  - LIMIT (bitfield): any combination of LIMIT_XMIN, LIMIT_XMAX, 
122                          LIMIT_YMIN, LIMIT_YMAX, LIMIT_ZMIN, LIMIT_ZMAX 
123                  - XMIN (float): clamped to [0.0001,1000.0] 
124                  - XMAX (float): clamped to [0.0001,1000.0] 
125                  - YMIN (float): clamped to [0.0001,1000.0] 
126                  - YMAX (float): clamped to [0.0001,1000.0] 
127                  - ZMIN (float): clamped to [0.0001,1000.0] 
128                  - ZMAX (float): clamped to [0.0001,1000.0] 
129          - Used by Limit Distance (LIMITDIST) constraint: 
130                  - LIMITMODE (int): any one of LIMIT_INSIDE, LIMIT_OUTSIDE, LIMIT_ONSURFACE 
131          - Used by Python Script (PYTHON) constraint: 
132                  - SCRIPT (Text): script to use 
133                  - PROPERTIES (IDProperties): ID-Properties of constraint 
134          - Used by Child Of (CHILDOF) constraint: 
135                  - COPY (bitfield): any combination of PARLOCX, PARLOCY, PARLOCZ,  
136                          PARROTX, PARROTY, PARROTZ, PARSIZEX, PARSIZEY, PARSIZEZ. 
137          - Used by Transformation (TRANSFORM) constraint: 
138                  - FROM (int): values are LOC, ROT, SCALE 
139                  - TO (int): values are LOC, ROT, SCALE 
140                  - MAPX, MAPY, MAPZ (int): values are LOC, ROT, SCALE 
141                  - EXTRAPOLATE (bool) 
142                  - FROM_MINX, FROM_MINY, FROM_MINZ, FROM_MAXX,  
143                    FROM_MAXY, FROM_MAXZ (float): 
144                    If FROM==LOC, then is clamped to [-1000.0, 1000.0] 
145                    If FROM==ROT, then is clamped to [-360.0, 360.0] 
146                    If FROM==SCALE, then is clamped to [0.0001, 1000.0] 
147                  - TO_MINX, TO_MINY, TO_MINZ, TO_MAXX, TO_MAXY, TO_MAXZ (float): 
148                    If TO==LOC, then is clamped to [-1000.0, 1000.0] 
149                    If TO==ROT, then is clamped to [-360.0, 360.0] 
150                    If TO==SCALE, then is clamped to [0.0001, 1000.0] 
151   
152  """ 
153   
154 -class Constraints:
155 """ 156 The Constraints object 157 ====================== 158 This object provides access to sequence of 159 L{constraints<Constraint.Constraint>} for a particular object. 160 They can be accessed from L{Object.constraints<Object.Object.constraints>}. 161 or L{PoseBone.constraints<Pose.PoseBone.constraints>}. 162 """ 163
164 - def __getitem__(index):
165 """ 166 This operator returns one of the constraints in the stack. 167 @type index: int 168 @return: an Constraint object 169 @rtype: Constraint 170 @raise KeyError: index was out of range 171 """
172
173 - def __len__():
174 """ 175 Returns the number of constraints in the constraint stack. 176 @return: number of Constraints 177 @rtype: int 178 """
179
180 - def append(type):
181 """ 182 Appends a new constraint to the end of the constraint stack. 183 @param type: a constant specifying the type of constraint to create. as from L{Type} 184 @type type: int constant 185 @rtype: Constraint 186 @return: the new Constraint 187 """
188
189 - def remove(con):
190 """ 191 Remove a constraint from this objects constraint sequence. 192 @param con: a constraint from this sequence to remove. 193 @type con: Constraint 194 @note: Accessing attributes of the constraint after it is removed will 195 throw an exception. 196 """
197
198 - def moveUp(con):
199 """ 200 Moves the constraint up in the object's constraint stack. 201 @param con: a constraint from this sequence to remove. 202 @type con: Constraint 203 @rtype: None 204 """
205
206 - def moveDown(con):
207 """ 208 Moves the constraint down in the object's constraint stack. 209 @param con: a constraint from this sequence to remove. 210 @type con: Constraint 211 @rtype: None 212 """
213
214 -class Constraint:
215 """ 216 The Constraint object 217 ===================== 218 This object provides access to a constraint for a particular object 219 accessed from L{Constraints}. 220 @ivar name: The name of this constraint. 29 chars max. 221 @type name: string 222 @ivar type: The type of this constraint. Read-only. The returned value 223 matches the types in L{Type}. 224 @type type: int 225 @ivar influence: The influence value of the constraint. Valid values 226 are in the range [0.0,1.0]. 227 @type influence: float 228 """ 229
230 - def __getitem__(key):
231 """ 232 This operator returns one of the constraint's data attributes. 233 @param key: value from constraint's L{Constraint.Settings} constant 234 @type key: int constant 235 @return: the requested data 236 @rtype: varies 237 @raise KeyError: the key does not exist for the constraint 238 """
239
240 - def __setitem__(key):
241 """ 242 This operator changes one of the constraint's data attributes. 243 @param key: value from constraint's L{Constraint.Settings} constant 244 @type key: int constant 245 @raise KeyError: the key does not exist for the constraint 246 """
247
248 - def insertKey(frame):
249 """ 250 Adds an influence keyframe for the constraint Ipo. 251 @rtype: None 252 @param frame: the frame number at which to insert the key. 253 @type frame: float 254 """
255