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

Source Code for Module Modifier

  1  # Blender.Modifier module and the Modifier PyType object 
  2   
  3  """ 
  4  The Blender.Modifier submodule 
  5   
  6  B{New}:  
  7    -  Supports the new Cast and Smooth modifiers. 
  8   
  9  This module provides access to the Modifier Data in Blender. 
 10   
 11  Example:: 
 12    from Blender import * 
 13   
 14    ob = Object.Get('Cube')        # retrieve an object 
 15    mods = ob.modifiers            # get the object's modifiers 
 16    for mod in mods: 
 17      print mod,mod.name           # print each modifier and its name 
 18    mod = mods.append(Modifier.Types.SUBSURF) # add a new subsurf modifier 
 19    mod[Modifier.Settings.LEVELS] = 3     # set subsurf subdivision levels to 3 
 20   
 21   
 22  Example:: 
 23          # Apply a lattice to an object and get the deformed object 
 24          # Uses an object called 'Cube' and a lattice called 'Lattice' 
 25           
 26          from Blender import * 
 27          ob_mesh= Object.Get('Cube') 
 28          ob_lattice= Object.Get('Lattice') 
 29   
 30          myMeshMod = ob_mesh.modifiers 
 31          mod = myMeshMod.append(Modifier.Types.LATTICE) 
 32          mod[Modifier.Settings.OBJECT] = ob_lattice 
 33   
 34          ob_mesh.makeDisplayList() # Needed to apply the modifier 
 35   
 36          Window.RedrawAll() # View the change 
 37   
 38          deformed_mesh= Mesh.New() 
 39          deformed_mesh.getFromObject(ob_mesh.name) 
 40   
 41   
 42          # Print the deformed locations 
 43          for v in deformed_mesh.verts: 
 44                  print v.co 
 45   
 46   
 47   
 48  @type Types: readonly dictionary 
 49  @var Types: Constant Modifier dict used for  L{ModSeq.append} to a 
 50    modifier sequence and comparing with L{Modifier.type}: 
 51      - ARMATURE - type value for Armature modifiers 
 52      - ARRAY - type value for Array modifiers 
 53      - BEVEL - type value for Bevel modifiers     
 54      - BOOLEAN - type value for Boolean modifiers     
 55      - BUILD - type value for Build modifiers 
 56      - CAST - type value for Cast modifiers 
 57      - CURVE - type value for Curve modifiers 
 58      - DECIMATE - type value for Decimate modifiers 
 59      - DISPLACE - type value for Displace modifiers 
 60      - EDGESPLIT - type value for Edge Split modifiers 
 61      - LATTICE - type value for Lattice modifiers 
 62      - MESHDEFORM - type value for MeshDeform modifiers 
 63      - MASK - type value for Mask modifiers     
 64      - MIRROR - type value for Mirror modifiers 
 65      - SHRINKWRAP - type value for Shrinkwrap modifiers 
 66      - SIMPLEDEFORM - type value for SimpleDeform modifiers 
 67      - SMOOTH - type value for Smooth modifiers 
 68      - SUBSURF - type value for Subsurf modifiers  
 69      - WAVE - type value for Wave modifiers 
 70   
 71  @type Settings: readonly dictionary 
 72  @var Settings: Constant Modifier dict used for changing modifier settings. 
 73          - RENDER - Used for all modifiers (bool) If true, the modifier is enabled for rendering. 
 74          - REALTIME - Used for all modifiers (bool) If true, the modifier is enabled for interactive display. 
 75          - EDITMODE - Used for all modifiers (bool) If both REALTIME and EDITMODE are true, the modifier is enabled for interactive display while the object is in edit mode. 
 76          - ONCAGE - Used for all modifiers (bool) If true, the modifier is enabled for the editing cage during edit mode. 
 77   
 78          - OBJECT - Used for Armature, Lattice, Curve, Boolean, Array, Shrinkwrap and SimpleDeform (Object) 
 79          - VERTGROUP - Used for Armature, Lattice, Curve, Smooth, Cast, Shrinkwrap and SimpleDeform (String) 
 80          - LIMIT - Array, Mirror (float [0.0 - 1.0]) 
 81          - FLAG - Mirror and Wave (int) 
 82          - COUNT - Decimator Polycount (readonly) and Array (int) 
 83          - LENGTH - Build [1.0-300000.0] and Array [0.0 - 10000.0] (float) 
 84          - FACTOR - Smooth [-10.0, 10.0], Cast [-10.0, 10.0] and SimpleDeform [-10.0, 10.0] (float) 
 85          - ENABLE_X = Smooth and Cast (bool, default: True) 
 86          - ENABLE_Y = Smooth and Cast (bool, default: True) 
 87          - ENABLE_Z = Smooth and Cast (bool, default: True) 
 88          - TYPES - Subsurf, Cast, Shrinkwrap and SimpleDeform. For Subsurf it determines the subdivision algorithm - (int): 0 = Catmull-Clark; 1 = simple subdivision. For Cast it determines the shape to deform to = (int): 0 = Sphere; 1 = Cylinder; 2 = Cuboid. For Shrinkwrap it determines where it has to project = (int): 0 = Nearest surface; 1 = Project; 2 = Nearest vertex. For DeformMesh it determines the function to apply = (int): 1 = Twist; 2 = Bend; 3 = Taper; 4 = Stretch. 
 89   
 90          - LEVELS - Used for Subsurf only (int [0 - 6]). The number of subdivision levels used for interactive display. 
 91          - RENDLEVELS - Used for Subsurf only (int [0 - 6]). The number of subdivision levels used for rendering. 
 92          - OPTIMAL - Used for Subsurf only (bool). Enables Optimal Draw. 
 93          - UV - Used for Subsurf only (bool). Enables Subsurf UV. 
 94   
 95          - OBJECT_OFFSET - Used for Array only (Object) 
 96          - OBJECT_CURVE - Used for Array only (Curve Object) 
 97          - OFFSET_VEC - Used for Array only (3d Vector) 
 98          - SCALE_VEC - Used for Array only (3d Vector) 
 99          - MERGE_DIST - Used for Array only (float) 
100   
101          - INVERT_VERTGROUP - Used for Armature only (bool) 
102          - ENVELOPES - Used for Armature only (bool) 
103          - VGROUPS - Used for Armature only (bool) 
104          - QUATERNION - Used for Armature only (bool) 
105          - B_BONE_REST - Used for Armature only (bool) 
106          - MULTIMODIFIER - Used for Armature only (bool) 
107           
108          - START - Used for Build only (int) 
109          - SEED - Used for Build only (int) 
110          - RANDOMIZE - Used for Build only (bool) 
111   
112          - AXIS_X - Used for Mirror only (bool) 
113          - AXIS_Y - Used for Mirror only (bool) 
114          - AXIS_Z - Used for Mirror only (bool) 
115   
116          - RATIO - Used for Decimate only (float [0.0 - 1.0]) 
117           
118          - STARTX - Used for Wave only (float [-100.0 - 100.0]) 
119          - STARTY - Used for Wave only (float [-100.0 - 100.0]) 
120          - HEIGHT - Used for Wave only (float [-2.0 - 2.0]) 
121          - WIDTH - Used for Wave only (float [0.0 - 5.0]) 
122          - NARROW - Used for Wave only (float [0.0 - 10.0]) 
123          - SPEED - Used for Wave only (float [-2.0 - 2.0]) 
124          - DAMP - Used for Wave only (float [-MAXFRAME - MAXFRAME]) 
125          - LIFETIME - Used for Wave only (float [-MAXFRAME - MAXFRAME]) 
126          - TIMEOFFS - Used for Wave only (float [-MAXFRAME - MAXFRAME]) 
127           
128          - OPERATION - Used for boolean only (int 0,1,2 : Intersect, Union, Difference) 
129           
130          - EDGESPLIT_ANGLE - Used for edge split only (float 0.0 - 180) 
131          - EDGESPLIT_FROM_ANGLE - Used for edge split only, should the modifier use the edge angle (bool) 
132          - EDGESPLIT_FROM_SHARP - Used for edge split only, should the modifier use the edge sharp flag (bool) 
133   
134          - UVLAYER - Used for Displace only 
135          - MID_LEVEL - Used for Displace only (float [0.0, 1.0], default: 0.5) 
136          - STRENGTH - Used for Displace only (float [-1000.0, 1000.0, default: 1.0) 
137          - TEXTURE - Used for Displace only (Texture object) 
138          - MAPPING - Used for Displace only 
139          - DIRECTION - Used for Displace only 
140   
141          - REPEAT - Used for Smooth only (int [0, 30], default: 1) 
142   
143          - RADIUS - Used for Cast only (float [0.0, 100.0], default: 0.0) 
144          - SIZE - Used for Cast only (float [0.0, 100.0], default: 0.0) 
145          - SIZE_FROM_RADIUS - Used for Cast only (bool, default: True) 
146          - USE_OB_TRANSFORM - Used for Cast only (bool, default: False) 
147   
148          - OBJECT_AUX - Used for Shrinkwrap only,  (Object) 
149          - KEEPDIST - Used for Shrinkwrap only (float [-1000.0, 1000.0, default: 0.0) 
150          - PROJECT_OVER_X_AXIS - Used for Shrinkwrap only, should the modifier not project over normal (bool) 
151          - PROJECT_OVER_Y_AXIS - Used for Shrinkwrap only, should the modifier not project over normal (bool) 
152          - PROJECT_OVER_Z_AXIS - Used for Shrinkwrap only, should the modifier not project over normal (bool) 
153          - PROJECT_OVER_NORMAL - Used for Shrinkwrap only (bool) 
154          - ALLOW_POS_DIR - Used for Shrinkwrap only, should the modifier use Project TYPES (bool)  
155          - ALLOW_NEG_DIR - Used for Shrinkwrap only, should the modifier use Project TYPES (bool) 
156          - CULL_TARGET_FRONTFACE - Used for Shrinkwrap only, should the modifier use Project TYPES (bool) 
157          - CULL_TARGET_BACKFACE - Used for Shrinkwrap only, should the modifier use Project TYPES (bool) 
158          - KEEP_ABOVE_SURFACE - Used for Shrinkwrap only , should the modifier use Nearest Surface TYPES(bool) 
159          - SUBSURFLEVELS - Used for Shrinkwrap only (int [0 - 6]). The number of subdivision levels used. 
160   
161          - RELATIVE - Used for Simpledeform only (bool, default: False)  
162          - LOWER_LIMIT - Used for Simpledeform only (float [0.0, UPPER_LIMIT], default: 0.0)) 
163          - UPPER_LIMIT - Used for Simpledeform only (float [LOWER_LIMIT,1.0], default: 1.0)) 
164          - LOCK_AXIS_X - Used for Simpledeform only (bool, default: False) 
165          - LOCK_AXIS_Y - Used for Simpledeform only (bool, default: False) 
166   
167  """ 
168   
169 -class ModSeq:
170 """ 171 The ModSeq object 172 ================= 173 This object provides access to list of L{modifiers<Modifier.Modifier>} for a particular object. 174 Only accessed from L{Object.Object.modifiers}. 175 """ 176
177 - def __getitem__(index):
178 """ 179 This operator returns one of the object's modifiers. 180 @type index: int 181 @return: an Modifier object 182 @rtype: Modifier 183 @raise KeyError: index was out of range 184 """
185
186 - def __len__():
187 """ 188 Returns the number of modifiers in the object's modifier stack. 189 @return: number of Modifiers 190 @rtype: int 191 """
192
193 - def append(type):
194 """ 195 Appends a new modifier to the end of the object's modifier stack. 196 @type type: a constant specifying the type of modifier to create. as from L{Types} 197 @rtype: Modifier 198 @return: the new Modifier 199 """
200
201 - def remove(modifier):
202 """ 203 Remove a modifier from this objects modifier sequence. 204 @type modifier: a modifier from this sequence to remove. 205 @note: Accessing attributes of the modifier after removing will raise an error. 206 """
207
208 - def moveUp(modifier):
209 """ 210 Moves the modifier up in the object's modifier stack. 211 @type modifier: a modifier from this sequence to remove. 212 @rtype: None 213 @raise RuntimeError: request to move above another modifier requiring 214 original data 215 @note: Accessing attributes of the modifier after removing will raise an error. 216 """
217
218 - def moveDown(modifier):
219 """ 220 Moves the modifier down in the object's modifier stack. 221 @type modifier: a modifier from this sequence to remove. 222 @rtype: None 223 @raise RuntimeError: request to move modifier beyond a non-deforming 224 modifier 225 @note: Accessing attributes of the modifier after removing will raise an error. 226 """
227
228 -class Modifier:
229 """ 230 The Modifier object 231 =================== 232 This object provides access to a modifier for a particular object accessed 233 from L{ModSeq}. 234 @ivar name: The name of this modifier. 31 chars max. 235 @type name: string 236 @ivar type: The type of this modifier. Read-only. The returned value 237 matches the types in L{Types}. 238 @type type: int 239 """ 240
241 - def __getitem__(key):
242 """ 243 This operator returns one of the modifier's data attributes. 244 @type key: value from modifier's L{Modifier.Settings} constant 245 @return: the requested data 246 @rtype: varies 247 @raise KeyError: the key does not exist for the modifier 248 """
249
250 - def __setitem__(key):
251 """ 252 This operator modifiers one of the modifier's data attributes. 253 @type key: value from modifier's L{Modifier.Settings} constant 254 @raise KeyError: the key does not exist for the modifier 255 """
256