Paste Code
Paste Blends
Paste Images
# First import bpy to get access to well... everything in blender
import bpy
import math, mathutils, random

# transStep ---------------------------------------->
def transStep(dA, sA, srA, rA, dR, sR, rR, axis_x, axis_y, axis_z):
bpy.ops.transform.shrink_fatten(value=-dA+(dR*random.uniform(-0.5, 0.5)), mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1, snap=False, snap_target='CLOSEST', snap_point=(0, 0, 0), snap_align=False, snap_normal=(0, 0, 0), release_confirm=False)
bpy.ops.transform.resize(value=(sA+(sR*random.uniform(-0.5, 0.5)), (sA+(sR*random.uniform(-0.5, 0.5)))*srA, sA+(sR*random.uniform(-0.5, 0.5))), constraint_axis=(False, False, False), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=0.0762767, snap=False, snap_target='CLOSEST', snap_point=(0, 0, 0), snap_align=False, snap_normal=(0, 0, 0), texture_space=False, release_confirm=False)\

# Get the mesh
me = ob.data
# Loop through the faces to find the center
for f in me.faces:
if f.select == True:
center = f.center
if center[0] > 0.0:
rotDir = 1.0
else:
rotDir = -1.0

bpy.ops.transform.rotate(value=(rA*rotDir+(rR*random.uniform(-0.5, 0.5)),), axis=(axis_x, axis_y, axis_z), constraint_axis=(False, False, False), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=0.0762767, snap=False, snap_target='CLOSEST', snap_point=(0, 0, 0), snap_align=False, snap_normal=(0, 0, 0), release_confirm=False)

# transformFaces! ------------------------------------------------------->
def transformFaces(vGroup, step, distArray, distRandom, scaleArray, scaleRatioArray, scaleRandom, rotArray, rotRandom, axis):
# Make sure nothing is selected
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='DESELECT')

# Select the vertex group
selPart(vGroup)

# Go into object mode so that we are sure we have the current list of faces
bpy.ops.object.mode_set(mode='OBJECT')

# Make a nice list to keep the vertex groups in
groupList = []

# Now loop through all the faces
for i, f in enumerate(ob.data.faces):

# If this face is selected~
if ob.data.faces[i].select == True:

# Create a new vertex group!
newGroup = ob.vertex_groups.new('mygroup')
groupList.append(newGroup)

# Get all the vertices in the current face and add them to the new group
for v in f.vertices:
newGroup.add([v], 1.0, 'REPLACE')

# Now we loop through the groups and do what we want.
for g in groupList:

# Make sure nothing is selected
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='DESELECT')

# Make the group in our list the active one
ob.vertex_groups.active_index = g.index

# Select all the verts in the active group
bpy.ops.object.vertex_group_select()

bpy.ops.object.vertex_group_remove(all=False)

# AND NOW WE CAN DO OUR STUFF... little test example follows

# Shape
for i in range(step):

bpy.ops.mesh.extrude(type='REGION')

# An added trick... remove the extruded face from all vertex groups after the first extrusion (i == 0)
# This way it can't get extruded again
# Because the edge of the first face can be part of multiple groups
if not i:
bpy.ops.object.vertex_group_remove_from(all=True)

bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.mode_set(mode='EDIT')

dA = distArray[i]
sA = scaleArray[i]
srA = scaleRatioArray[i]
rA = rotArray[i]
dR = distRandom
sR = scaleRandom
rR = rotRandom
axis_x = axis[0]
axis_y = axis[1]
axis_z = axis[2]
transStep(dA, sA, srA, rA, dR, sR, rR, axis_x, axis_y, axis_z)

#bpy.ops.object.vertex_group_set_active(group='legTop')
#bpy.ops.object.vertex_group_assign(new=False)

# transformFaces!(END) --------------------------------------------------<

# transformRegion! ---------------------------------------------------->
def transformRegion(vGroup, step, distArray, distRandom, scaleArray, scaleRatioArray, scaleRandom, rotArray, rotRandom, axis):
# Make sure nothing is selected
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='DESELECT')
selPart(vGroup)

# Loop through all the areas
for area in areas:

# See if the current area is a 3D view
if area.type == 'VIEW_3D':

# Set the pivot point to individual origins
area.active_space.pivot_point = 'BOUNDING_BOX_CENTER'

# Shape
for i in range(step):

bpy.ops.mesh.extrude(type='REGION')

# An added trick... remove the extruded face from all vertex groups after the first extrusion (i == 0)
# This way it can't get extruded again
# Because the edge of the first face can be part of multiple groups
if not i:
bpy.ops.object.vertex_group_remove_from(all=True)

bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.mode_set(mode='EDIT')

dA = distArray[i]
sA = scaleArray[i]
srA = scaleRatioArray[i]
rA = rotArray[i]
dR = distRandom
sR = scaleRandom
rR = rotRandom
axis_x = axis[0]
axis_y = axis[1]
axis_z = axis[2]
transStep(dA, sA, srA, rA, dR, sR, rR, axis_x, axis_y, axis_z)

bpy.ops.mesh.select_all(action='DESELECT')

# transformRegion(END) ----------------------------------------------------<

# bellyMaker ------------------------------------------------------>
def bellyMaker(vGroup, step, distArray, distRandom, scaleArray, scaleRatioArray, scaleRandom, rotArray, rotRandom, axisArray, ):
newGroup = ob.vertex_groups.new(vGroup)
bpy.ops.object.mode_set(mode='OBJECT')

# Lets loop through all the faces in the mesh
for f in ob.data.faces:

# See if the current face's centre is above 0.0 on the Z axis
if f.center[1] > 0.1:
# Set select to true
f.select = True
else:
f.select = False

bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.object.vertex_group_set_active(group=vGroup)
bpy.ops.object.vertex_group_assign(new=False)

transformFaces(vGroup, step, distArray, distRandom, scaleArray, scaleRatioArray, scaleRandom, rotArray, rotRandom, axisArray)
bpy.ops.object.vertex_group_remove(all=False)

# bellyMaker(END) -------------------------------------------------<

# headMaker ------------------------------------------------------>
def headMaker(vGroup, step, distArray, distRandom, scaleArray, scaleRatioArray, scaleRandom, rotArray, rotRandom, axisArray, ):
newGroup = ob.vertex_groups.new(vGroup)
bpy.ops.object.mode_set(mode='OBJECT')

# Lets loop through all the faces in the mesh
for f in ob.data.faces:

# See if the current face's centre is above 0.0 on the Z axis
if f.center[1] < -0.1:
# Set select to true
f.select = True
else:
f.select = False

bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.object.vertex_group_set_active(group=vGroup)
bpy.ops.object.vertex_group_assign(new=False)

transformFaces(vGroup, step, distArray, distRandom, scaleArray, scaleRatioArray, scaleRandom, rotArray, rotRandom, axisArray)
bpy.ops.object.vertex_group_remove(all=False)
newGroup = ob.vertex_groups.new('mouth')
bpy.ops.object.vertex_group_set_active(group='mouth')
bpy.ops.object.vertex_group_assign(new=False)

# headMaker(END) -------------------------------------------------<

# select faces from Groups
def selPart(vGroup):
bpy.ops.object.vertex_group_set_active(group=vGroup)
bpy.ops.object.vertex_group_select()

# cell subdivide --------------------------------------------->
def cellSubdiv():
bpy.ops.object.modifier_add(type='SUBSURF')
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Subsurf")

# assignFaces
def assignFaces(vGroup, xMin, xMax, yMin, yMax, zMin, zMax):
newGroup = ob.vertex_groups.new(vGroup)
bpy.ops.object.mode_set(mode='OBJECT')

for f in ob.data.faces:

# See if the current face's centre is above 0.0 on the Z axis
if f.center[0] > xMin and f.center[0] < xMax:
if f.center[1] > yMin and f.center[1] < yMax:
if f.center[2] > zMin and f.center[2] < zMax:
# Set select to true
f.select = True
else:
f.select = False

bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.object.vertex_group_set_active(group=vGroup)
bpy.ops.object.vertex_group_assign(new=False)
bpy.ops.mesh.select_all(action='DESELECT')

# -- Set Up(START) ------------------------------------------>
# Now we want to get the active object
# To do this we go through bpy.context... because that is basicly "what you are working on right now"
# bpy.data could work too, but then you'd need to do more work to find your current active object
ob = bpy.context.active_object

# A new trick... lets go into edit mode and deselect everything ('SELECT' works too)
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='DESELECT')

# Get the screen areas we are working in right now
areas = bpy.context.screen.areas

# Loop through all the areas
for area in areas:

# See if the current area is a 3D view
if area.type == 'VIEW_3D':

# Set the pivot point to individual origins
area.active_space.pivot_point = 'INDIVIDUAL_ORIGINS'

# -- Set Up(END) ------------------------------------------<

# Generate Object
# body and head
bellyMaker('belly', 5, [0.4, 0.2, 3, 2, 0.5], 0.0, [0.3, 1.0, 5, 0.1, 1.0], [1.0, 1.0, 1.0, 1.0, 1.0], 0.0, [-0.2, -0.2, -0.2, -0.2, 0.0], 0.0, [-1, -2.22045e-16, -0])
headMaker('head', 4, [0.4, 0.4, 0.6, 0.8], 0.0, [0.4, 1.2, 2.0, 0.5], [1.0, 1.0, 1.0, 1.0], 0.0, [-0.2, -0.2, 0.4, 0.2], 0.0, [-1, -2.22045e-16, -0])
# mouth
transformRegion('mouth', 4, [0.3, 0.6, 0, -0.3], 0.0, [0.6, 0.4, 0.8, 1.0], [1.0, 1.0, 1.0, 1.0], 0.0, [0.7, -0.5, 0.0, 0.0], 0.0, [-1, -2.22045e-16, -0])
cellSubdiv()

# select parts basement faces
assignFaces('leg', -1.0, 1.0, -2.0, 2.0, -2.0, -0.5)
assignFaces('eye_1', -2.0, 2.0, -3.2, -2.0, 0.5, 1.5)
assignFaces('spine', -2.0, 2.0, 1.5, 6.0, 0.0, 3.0)
assignFaces('arm', -2.0, 2.0, -1.2, 1.2, 0.0, 3.0)

# transformFaces(vGroup, step, distArray, distRandom, scaleArray, scaleRatioArray, scaleRandom, rotArray, rotRandom, axisArray)
transformFaces('spine', 3, [0.05, 0.1, 0.15], 0.0, [0.5, 0.5, 0.5], [1.5, 1.0, 1.0], 0.0, [0.0, 0.0, 0.0], 0.0, [-0, 1, -3.42285e-08])
transformFaces('arm', 5, [0.1, 0.4, 0.4, 0.4, 0.3], 0.0, [0.3, 1.8, 1.1, 0.5, 0.1], [1.0, 1.0, 1.0, 1.0, 1.0], 0.0, [0.0, -0.3, 0.3, 0.3, -0.3], 0.0, [-0, 1, -3.42285e-08])
transformFaces('eye_1', 5, [0.06, 0.015, 0.0, 0.05, 0.01], 0.0, [0.7, 0.8, 0.95, 0.7, 0.2], [1.1, 1.1, 1.1, 1.1, 1.1], 0.0, [0.0, 0.0, 0.0, 0.0, 0.0], 0.0, [-0, 1, -3.42285e-08])
#transformFaces('eye_2', 7, [0.06, 0.015, 0.0, 0.2, 0.05, 0.0, -0.1], 0.0, [1.0, 0.8, 0.95, 0.5, 0.3, 0.8, 1.0], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 0.0, [0.0, 0.0, -0.2, 0.0, 0.0, 0.0, 0.0, 0.0], 0.0, [-0, 1, -3.42285e-08])
transformFaces('leg', 6, [0.1, 0.7, 0.02, 0.02, 1.0, 0.1], 0.0, [0.3, 1.6, 0.8, 1.2, 0.4, 0.1], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 0.0, [-0.3, -0.8, 0.0, 0.0, 1.0, 0.0], 0.0, [-0, 1, -3.42285e-08])
# transformRegion(vGroup, step, distArray, distRandom, scaleArray, scaleRatioArray, scaleRandom, rotArray, rotRandom, axisArray)
  1. # First import bpy to get access to well... everything in blender
  2. import bpy
  3. import math, mathutils, random
  4.        
  5. # transStep ---------------------------------------->
  6. def transStep(dA, sA, srA, rA, dR, sR, rR, axis_x, axis_y, axis_z):
  7.         bpy.ops.transform.shrink_fatten(value=-dA+(dR*random.uniform(-0.5, 0.5)), mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1, snap=False, snap_target='CLOSEST', snap_point=(0, 0, 0), snap_align=False, snap_normal=(0, 0, 0), release_confirm=False)
  8.         bpy.ops.transform.resize(value=(sA+(sR*random.uniform(-0.5, 0.5)), (sA+(sR*random.uniform(-0.5, 0.5)))*srA, sA+(sR*random.uniform(-0.5, 0.5))), constraint_axis=(False, False, False), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=0.0762767, snap=False, snap_target='CLOSEST', snap_point=(0, 0, 0), snap_align=False, snap_normal=(0, 0, 0), texture_space=False, release_confirm=False)\
  9.        
  10.         # Get the mesh
  11.         me = ob.data
  12.         # Loop through the faces to find the center
  13.         for f in me.faces:
  14.                 if f.select == True:
  15.                         center = f.center
  16.         if center[0] > 0.0:
  17.                 rotDir = 1.0
  18.         else:
  19.                 rotDir = -1.0
  20.                
  21.         bpy.ops.transform.rotate(value=(rA*rotDir+(rR*random.uniform(-0.5, 0.5)),), axis=(axis_x, axis_y, axis_z), constraint_axis=(False, False, False), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=0.0762767, snap=False, snap_target='CLOSEST', snap_point=(0, 0, 0), snap_align=False, snap_normal=(0, 0, 0), release_confirm=False)
  22.  
  23. # transformFaces! ------------------------------------------------------->
  24. def transformFaces(vGroup, step, distArray, distRandom, scaleArray, scaleRatioArray, scaleRandom, rotArray, rotRandom, axis):
  25.         # Make sure nothing is selected
  26.         bpy.ops.object.mode_set(mode='EDIT')
  27.         bpy.ops.mesh.select_all(action='DESELECT')
  28.        
  29.         # Select the vertex group
  30.         selPart(vGroup)
  31.  
  32.         # Go into object mode so that we are sure we have the current list of faces
  33.         bpy.ops.object.mode_set(mode='OBJECT')
  34.  
  35.         # Make a nice list to keep the vertex groups in
  36.         groupList = []
  37.  
  38.         # Now loop through all the faces
  39.         for i, f in enumerate(ob.data.faces):
  40.  
  41.                 # If this face is selected~
  42.                 if ob.data.faces[i].select == True:
  43.  
  44.                         # Create a new vertex group!
  45.                         newGroup = ob.vertex_groups.new('mygroup')
  46.                         groupList.append(newGroup)
  47.  
  48.                         # Get all the vertices in the current face and add them to the new group
  49.                         for v in f.vertices:
  50.                                 newGroup.add([v], 1.0, 'REPLACE')
  51.                        
  52. # Now we loop through the groups and do what we want.
  53.         for g in groupList:
  54.  
  55.                 # Make sure nothing is selected
  56.                 bpy.ops.object.mode_set(mode='EDIT')
  57.                 bpy.ops.mesh.select_all(action='DESELECT')
  58.  
  59.                 # Make the group in our list the active one
  60.                 ob.vertex_groups.active_index = g.index
  61.  
  62.                 # Select all the verts in the active group
  63.                 bpy.ops.object.vertex_group_select()
  64.  
  65.                 bpy.ops.object.vertex_group_remove(all=False)
  66.  
  67.                 # AND NOW WE CAN DO OUR STUFF... little test example follows
  68.  
  69.                 # Shape
  70.                 for i in range(step):
  71.      
  72.                         bpy.ops.mesh.extrude(type='REGION')
  73.  
  74.                         # An added trick... remove the extruded face from all vertex groups after the first extrusion (i == 0)
  75.                         # This way it can't get extruded again
  76.                         # Because the edge of the first face can be part of multiple groups
  77.                         if not i:
  78.                                 bpy.ops.object.vertex_group_remove_from(all=True)
  79.          
  80.                         bpy.ops.object.mode_set(mode='OBJECT')
  81.                         bpy.ops.object.mode_set(mode='EDIT')
  82.  
  83.                         dA = distArray[i]
  84.                         sA = scaleArray[i]
  85.                         srA = scaleRatioArray[i]
  86.                         rA = rotArray[i]
  87.                         dR = distRandom
  88.                         sR = scaleRandom
  89.                         rR = rotRandom
  90.                         axis_x = axis[0]
  91.                         axis_y = axis[1]
  92.                         axis_z = axis[2]
  93.                         transStep(dA, sA, srA, rA, dR, sR, rR, axis_x, axis_y, axis_z)
  94.  
  95.                 #bpy.ops.object.vertex_group_set_active(group='legTop')
  96.                 #bpy.ops.object.vertex_group_assign(new=False)
  97.        
  98. # transformFaces!(END) --------------------------------------------------<
  99.  
  100. # transformRegion! ---------------------------------------------------->
  101. def transformRegion(vGroup, step, distArray, distRandom, scaleArray, scaleRatioArray, scaleRandom, rotArray, rotRandom, axis):
  102.         # Make sure nothing is selected
  103.         bpy.ops.object.mode_set(mode='EDIT')
  104.         bpy.ops.mesh.select_all(action='DESELECT')
  105.         selPart(vGroup)
  106.        
  107.         # Loop through all the areas
  108.         for area in areas:
  109.  
  110.                 # See if the current area is a 3D view
  111.                 if area.type == 'VIEW_3D':
  112.  
  113.                         # Set the pivot point to individual origins
  114.                         area.active_space.pivot_point = 'BOUNDING_BOX_CENTER'   
  115.        
  116.         # Shape
  117.         for i in range(step):
  118.      
  119.                 bpy.ops.mesh.extrude(type='REGION')
  120.  
  121.                 # An added trick... remove the extruded face from all vertex groups after the first extrusion (i == 0)
  122.                 # This way it can't get extruded again
  123.                 # Because the edge of the first face can be part of multiple groups
  124.                 if not i:
  125.                         bpy.ops.object.vertex_group_remove_from(all=True)
  126.          
  127.                 bpy.ops.object.mode_set(mode='OBJECT')
  128.                 bpy.ops.object.mode_set(mode='EDIT')
  129.  
  130.                 dA = distArray[i]
  131.                 sA = scaleArray[i]
  132.                 srA = scaleRatioArray[i]
  133.                 rA = rotArray[i]
  134.                 dR = distRandom
  135.                 sR = scaleRandom
  136.                 rR = rotRandom
  137.                 axis_x = axis[0]
  138.                 axis_y = axis[1]
  139.                 axis_z = axis[2]
  140.                 transStep(dA, sA, srA, rA, dR, sR, rR, axis_x, axis_y, axis_z)
  141.                        
  142.         bpy.ops.mesh.select_all(action='DESELECT')
  143.                
  144. # transformRegion(END) ----------------------------------------------------<
  145.        
  146. # bellyMaker ------------------------------------------------------>
  147. def bellyMaker(vGroup, step, distArray, distRandom, scaleArray, scaleRatioArray, scaleRandom, rotArray, rotRandom, axisArray, ):
  148.         newGroup = ob.vertex_groups.new(vGroup)
  149.         bpy.ops.object.mode_set(mode='OBJECT')
  150.        
  151.         # Lets loop through all the faces in the mesh
  152.         for f in ob.data.faces:
  153.        
  154.                 # See if the current face's centre is above 0.0 on the Z axis
  155.                 if f.center[1] > 0.1:
  156.                         # Set select to true
  157.                         f.select = True
  158.                 else:
  159.                         f.select = False
  160.                
  161.         bpy.ops.object.mode_set(mode='EDIT')                   
  162.         bpy.ops.object.vertex_group_set_active(group=vGroup)
  163.         bpy.ops.object.vertex_group_assign(new=False)
  164.        
  165.         transformFaces(vGroup, step, distArray, distRandom, scaleArray, scaleRatioArray, scaleRandom, rotArray, rotRandom, axisArray)
  166.         bpy.ops.object.vertex_group_remove(all=False)
  167.  
  168. # bellyMaker(END) -------------------------------------------------<
  169.  
  170. # headMaker ------------------------------------------------------>
  171. def headMaker(vGroup, step, distArray, distRandom, scaleArray, scaleRatioArray, scaleRandom, rotArray, rotRandom, axisArray, ):
  172.         newGroup = ob.vertex_groups.new(vGroup)
  173.         bpy.ops.object.mode_set(mode='OBJECT')
  174.        
  175.         # Lets loop through all the faces in the mesh
  176.         for f in ob.data.faces:
  177.        
  178.                 # See if the current face's centre is above 0.0 on the Z axis
  179.                 if f.center[1] < -0.1:
  180.                         # Set select to true
  181.                         f.select = True
  182.                 else:
  183.                         f.select = False
  184.                
  185.         bpy.ops.object.mode_set(mode='EDIT')                   
  186.         bpy.ops.object.vertex_group_set_active(group=vGroup)
  187.         bpy.ops.object.vertex_group_assign(new=False)
  188.        
  189.         transformFaces(vGroup, step, distArray, distRandom, scaleArray, scaleRatioArray, scaleRandom, rotArray, rotRandom, axisArray)
  190.         bpy.ops.object.vertex_group_remove(all=False)
  191.         newGroup = ob.vertex_groups.new('mouth')
  192.         bpy.ops.object.vertex_group_set_active(group='mouth')
  193.         bpy.ops.object.vertex_group_assign(new=False)
  194.  
  195. # headMaker(END) -------------------------------------------------<
  196.  
  197. # select faces from Groups
  198. def selPart(vGroup):
  199.         bpy.ops.object.vertex_group_set_active(group=vGroup)
  200.         bpy.ops.object.vertex_group_select()
  201.        
  202. # cell subdivide --------------------------------------------->
  203. def cellSubdiv():
  204.         bpy.ops.object.modifier_add(type='SUBSURF')
  205.         bpy.ops.object.mode_set(mode='OBJECT')
  206.         bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Subsurf")
  207.  
  208. # assignFaces
  209. def assignFaces(vGroup, xMin, xMax, yMin, yMax, zMin, zMax):
  210.         newGroup = ob.vertex_groups.new(vGroup)
  211.         bpy.ops.object.mode_set(mode='OBJECT')
  212.        
  213.         for f in ob.data.faces:
  214.        
  215.                 # See if the current face's centre is above 0.0 on the Z axis
  216.                 if f.center[0] > xMin and f.center[0] < xMax:
  217.                         if f.center[1] > yMin and f.center[1] < yMax:
  218.                                 if f.center[2] > zMin and f.center[2] < zMax:
  219.                                         # Set select to true
  220.                                         f.select = True
  221.                                 else:
  222.                                         f.select = False
  223.                                        
  224.         bpy.ops.object.mode_set(mode='EDIT')                   
  225.         bpy.ops.object.vertex_group_set_active(group=vGroup)
  226.         bpy.ops.object.vertex_group_assign(new=False)
  227.         bpy.ops.mesh.select_all(action='DESELECT')
  228.        
  229. # -- Set Up(START) ------------------------------------------>
  230. # Now we want to get the active object
  231. # To do this we go through bpy.context... because that is basicly "what you are working on right now"
  232. # bpy.data could work too, but then you'd need to do more work to find your current active object
  233. ob = bpy.context.active_object
  234.  
  235. # A new trick... lets go into edit mode and deselect everything ('SELECT' works too)
  236. bpy.ops.object.mode_set(mode='EDIT')
  237. bpy.ops.mesh.select_all(action='DESELECT')
  238.  
  239. # Get the screen areas we are working in right now
  240. areas = bpy.context.screen.areas
  241.  
  242. # Loop through all the areas
  243. for area in areas:
  244.  
  245.         # See if the current area is a 3D view
  246.         if area.type == 'VIEW_3D':
  247.  
  248.                 # Set the pivot point to individual origins
  249.                 area.active_space.pivot_point = 'INDIVIDUAL_ORIGINS'
  250.  
  251. # -- Set Up(END) ------------------------------------------<
  252.  
  253. # Generate Object
  254.         # body and head
  255. bellyMaker('belly', 5, [0.4, 0.2, 3, 2, 0.5], 0.0, [0.3, 1.0, 5, 0.1, 1.0], [1.0, 1.0, 1.0, 1.0, 1.0], 0.0, [-0.2, -0.2, -0.2, -0.2, 0.0], 0.0, [-1, -2.22045e-16, -0])
  256. headMaker('head', 4, [0.4, 0.4, 0.6, 0.8], 0.0, [0.4, 1.2, 2.0, 0.5], [1.0, 1.0, 1.0, 1.0], 0.0, [-0.2, -0.2, 0.4, 0.2], 0.0, [-1, -2.22045e-16, -0])
  257.         # mouth
  258. transformRegion('mouth', 4, [0.3, 0.6, 0, -0.3], 0.0, [0.6, 0.4, 0.8, 1.0], [1.0, 1.0, 1.0, 1.0], 0.0, [0.7, -0.5, 0.0, 0.0], 0.0, [-1, -2.22045e-16, -0])
  259. cellSubdiv()
  260.  
  261.         # select parts basement faces
  262. assignFaces('leg', -1.0, 1.0, -2.0, 2.0, -2.0, -0.5)
  263. assignFaces('eye_1', -2.0, 2.0, -3.2, -2.0, 0.5, 1.5)
  264. assignFaces('spine', -2.0, 2.0, 1.5, 6.0, 0.0, 3.0)
  265. assignFaces('arm', -2.0, 2.0, -1.2, 1.2, 0.0, 3.0)
  266.  
  267. # transformFaces(vGroup, step, distArray, distRandom, scaleArray, scaleRatioArray, scaleRandom, rotArray, rotRandom, axisArray)
  268. transformFaces('spine', 3, [0.05, 0.1, 0.15], 0.0, [0.5, 0.5, 0.5], [1.5, 1.0, 1.0], 0.0, [0.0, 0.0, 0.0], 0.0, [-0, 1, -3.42285e-08])
  269. transformFaces('arm', 5, [0.1, 0.4, 0.4, 0.4, 0.3], 0.0, [0.3, 1.8, 1.1, 0.5, 0.1], [1.0, 1.0, 1.0, 1.0, 1.0], 0.0, [0.0, -0.3, 0.3, 0.3, -0.3], 0.0, [-0, 1, -3.42285e-08])
  270. transformFaces('eye_1', 5, [0.06, 0.015, 0.0, 0.05, 0.01], 0.0, [0.7, 0.8, 0.95, 0.7, 0.2], [1.1, 1.1, 1.1, 1.1, 1.1], 0.0, [0.0, 0.0, 0.0, 0.0, 0.0], 0.0, [-0, 1, -3.42285e-08])
  271. #transformFaces('eye_2', 7, [0.06, 0.015, 0.0, 0.2, 0.05, 0.0, -0.1], 0.0, [1.0, 0.8, 0.95, 0.5, 0.3, 0.8, 1.0], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 0.0, [0.0, 0.0, -0.2, 0.0, 0.0, 0.0, 0.0, 0.0], 0.0, [-0, 1, -3.42285e-08])
  272. transformFaces('leg', 6, [0.1, 0.7, 0.02, 0.02, 1.0, 0.1], 0.0, [0.3, 1.6, 0.8, 1.2, 0.4, 0.1], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 0.0, [-0.3, -0.8, 0.0, 0.0, 1.0, 0.0], 0.0, [-0, 1, -3.42285e-08])
  273. # transformRegion(vGroup, step, distArray, distRandom, scaleArray, scaleRatioArray, scaleRandom, rotArray, rotRandom, axisArray)
  274.  
go to heaven