Module Modifier

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      - BOOLEAN - type value for Boolean modifiers 
 54      - BUILD - type value for Build modifiers 
 55      - CURVE - type value for Curve modifiers 
 56      - MIRROR - type value for Mirror modifiers 
 57      - DECIMATE - type value for Decimate modifiers 
 58      - LATTICE - type value for Lattice modifiers 
 59      - SUBSURF - type value for Subsurf modifiers 
 60      - WAVE - type value for Wave modifiers 
 61      - EDGESPLIT - type value for Edge Split modifiers 
 62      - DISPLACE - type value for Displace modifiers 
 63      - SMOOTH - type value for Smooth modifiers 
 64      - CAST - type value for Cast modifiers 
 65   
 66  @type Settings: readonly dictionary 
 67  @var Settings: Constant Modifier dict used for changing modifier settings. 
 68          - RENDER - Used for all modifiers (bool) If true, the modifier is enabled for rendering. 
 69          - REALTIME - Used for all modifiers (bool) If true, the modifier is enabled for interactive display. 
 70          - 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. 
 71          - ONCAGE - Used for all modifiers (bool) If true, the modifier is enabled for the editing cage during edit mode. 
 72   
 73          - OBJECT - Used for Armature, Lattice, Curve, Boolean and Array (Object) 
 74          - VERTGROUP - Used for Armature, Lattice, Curve, Smooth and Cast (String) 
 75          - LIMIT - Array and Mirror (float [0.0 - 1.0]) 
 76          - FLAG - Mirror and Wave (int) 
 77          - COUNT - Decimator Polycount (readonly) and Array (int) 
 78          - LENGTH - Build [1.0-300000.0] and Array [0.0 - 10000.0] (float) 
 79          - FACTOR - Smooth [-10.0, 10.0] and Cast [-10.0, 10.0] (float) 
 80          - ENABLE_X = Smooth and Cast (bool, default: True) 
 81          - ENABLE_Y = Smooth and Cast (bool, default: True) 
 82          - ENABLE_Z = Smooth and Cast (bool, default: True) 
 83          - TYPES - Subsurf and Cast. 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 
 84   
 85          - LEVELS - Used for Subsurf only (int [0 - 6]). The number of subdivision levels used for interactive display. 
 86          - RENDLEVELS - Used for Subsurf only (int [0 - 6]). The number of subdivision levels used for rendering. 
 87          - OPTIMAL - Used for Subsurf only (bool). Enables Optimal Draw. 
 88          - UV - Used for Subsurf only (bool). Enables Subsurf UV. 
 89   
 90          - OBJECT_OFFSET - Used for Array only (Object) 
 91          - OBJECT_CURVE - Used for Array only (Curve Object) 
 92          - OFFSET_VEC - Used for Array only (3d Vector) 
 93          - SCALE_VEC - Used for Array only (3d Vector) 
 94          - MERGE_DIST - Used for Array only (float) 
 95   
 96          - ENVELOPES - Used for Armature only (bool) 
 97           
 98          - START - Used for Build only (int) 
 99          - SEED - Used for Build only (int) 
100          - RANDOMIZE - Used for Build only (bool) 
101   
102          - AXIS_X - Used for Mirror only (bool) 
103          - AXIS_Y - Used for Mirror only (bool) 
104          - AXIS_Z - Used for Mirror only (bool) 
105   
106          - RATIO - Used for Decimate only (float [0.0 - 1.0]) 
107           
108          - STARTX - Used for Wave only (float [-100.0 - 100.0]) 
109          - STARTY - Used for Wave only (float [-100.0 - 100.0]) 
110          - HEIGHT - Used for Wave only (float [-2.0 - 2.0]) 
111          - WIDTH - Used for Wave only (float [0.0 - 5.0]) 
112          - NARROW - Used for Wave only (float [0.0 - 10.0]) 
113          - SPEED - Used for Wave only (float [-2.0 - 2.0]) 
114          - DAMP - Used for Wave only (float [-MAXFRAME - MAXFRAME]) 
115          - LIFETIME - Used for Wave only (float [-MAXFRAME - MAXFRAME]) 
116          - TIMEOFFS - Used for Wave only (float [-MAXFRAME - MAXFRAME]) 
117           
118          - OPERATION - Used for boolean only (int 0,1,2 : Intersect, Union, Difference) 
119           
120          - EDGESPLIT_ANGLE - Used for edge split only (float 0.0 - 180) 
121          - EDGESPLIT_FROM_ANGLE - Used for edge split only, should the modifier use the edge angle (bool) 
122          - EDGESPLIT_FROM_SHARP - Used for edge split only, should the modifier use the edge sharp flag (bool) 
123   
124          - UVLAYER - Used for Displace only 
125          - MID_LEVEL - Used for Displace only (float [0.0, 1.0], default: 0.5) 
126          - STRENGTH - Used for Displace only (float [-1000.0, 1000.0, default: 1.0) 
127          - TEXTURE - Used for Displace only (string) 
128          - MAPPING - Used for Displace only 
129          - DIRECTION - Used for Displace only 
130   
131          - REPEAT - Used for Smooth only (int [0, 30], default: 1) 
132   
133          - RADIUS - Used for Cast only (float [0.0, 100.0], default: 0.0) 
134          - SIZE - Used for Cast only (float [0.0, 100.0], default: 0.0) 
135          - SIZE_FROM_RADIUS - Used for Cast only (bool, default: True) 
136          - USE_OB_TRANSFORM - Used for Cast only (bool, default: False) 
137  """ 
138   
139 -class ModSeq:
140 """ 141 The ModSeq object 142 ================= 143 This object provides access to list of L{modifiers<Modifier.Modifier>} for a particular object. 144 Only accessed from L{Object.Object.modifiers}. 145 """ 146
147 - def __getitem__(index):
148 """ 149 This operator returns one of the object's modifiers. 150 @type index: int 151 @return: an Modifier object 152 @rtype: Modifier 153 @raise KeyError: index was out of range 154 """
155
156 - def __len__():
157 """ 158 Returns the number of modifiers in the object's modifier stack. 159 @return: number of Modifiers 160 @rtype: int 161 """
162
163 - def append(type):
164 """ 165 Appends a new modifier to the end of the object's modifier stack. 166 @type type: a constant specifying the type of modifier to create. as from L{Types} 167 @rtype: Modifier 168 @return: the new Modifier 169 """
170
171 - def remove(modifier):
172 """ 173 Remove a modifier from this objects modifier sequence. 174 @type modifier: a modifier from this sequence to remove. 175 @note: Accessing attributes of the modifier after removing will raise an error. 176 """
177
178 - def moveUp(modifier):
179 """ 180 Moves the modifier up in the object's modifier stack. 181 @type modifier: a modifier from this sequence to remove. 182 @rtype: None 183 @raise RuntimeError: request to move above another modifier requiring 184 original data 185 @note: Accessing attributes of the modifier after removing will raise an error. 186 """
187
188 - def moveDown(modifier):
189 """ 190 Moves the modifier down in the object's modifier stack. 191 @type modifier: a modifier from this sequence to remove. 192 @rtype: None 193 @raise RuntimeError: request to move modifier beyond a non-deforming 194 modifier 195 @note: Accessing attributes of the modifier after removing will raise an error. 196 """
197
198 -class Modifier:
199 """ 200 The Modifier object 201 =================== 202 This object provides access to a modifier for a particular object accessed 203 from L{ModSeq}. 204 @ivar name: The name of this modifier. 31 chars max. 205 @type name: string 206 @ivar type: The type of this modifier. Read-only. The returned value 207 matches the types in L{Types}. 208 @type type: int 209 """ 210
211 - def __getitem__(key):
212 """ 213 This operator returns one of the modifier's data attributes. 214 @type key: value from modifier's L{Modifier.Settings} constant 215 @return: the requested data 216 @rtype: varies 217 @raise KeyError: the key does not exist for the modifier 218 """
219
220 - def __setitem__(key):
221 """ 222 This operator modifiers one of the modifier's data attributes. 223 @type key: value from modifier's L{Modifier.Settings} constant 224 @raise KeyError: the key does not exist for the modifier 225 """
226