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

span = 10
scale = 0.5

class GMP_Panel(bpy.types.Panel):
bl_label = "Generative Modeling"
bl_space_type = "VIEW_3D"
bl_region_type = "TOOLS"

def draw(self, context):
layout = self.layout

scn = bpy.context.scene

row = layout.row()
row.operator( "bpt.generate_op" )
row = layout.row()
row.operator( "bpt.reset_op" )

class GMP_Operator(bpy.types.Operator):
bl_idname = "bpt.generate_op"
bl_label = "Generate Variation"

def execute(self, context):
# Do 8 operations
clearAndSetNewObj()

return {'FINISHED'}

class GMP_Reset(bpy.types.Operator):
bl_idname = "bpt.reset_op"
bl_label = "Reset"

def execute(self, context):
# Reset
resetNewObj()

return {'FINISHED'}

def register():
bpy.utils.register_class( GMP_Operator )
bpy.utils.register_class( GMP_Reset )
bpy.utils.register_class( GMP_Panel )

def unregister():
bpy.utils.register_class( GMP_Operator )
bpy.utils.register_class( GMP_Reset )
bpy.utils.register_class( GMP_Panel )

# Reset Object
def resetNewObj():
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete()
addFirstCube()

# Add first cube
def addFirstCube():
bpy.ops.mesh.primitive_cube_add(view_align=False, enter_editmode=False, location=(0, 0, 0), rotation=(0, 0, 0), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))

# Add first vGroup
ob = bpy.context.active_object
newGroup = ob.vertex_groups.new('vGroup')

# clearAndSetNewObj
def clearAndSetNewObj():
bpy.ops.object.select_inverse()
bpy.ops.object.delete()
bpy.ops.object.select_all(action='SELECT')

# Move Selected Object to Center(0, 0, 0) ------------------
# So we make a list of all objects we're currently working with
obList = []

# First get the active object
ob = bpy.context.active_object

# Add this object to the list
obList.append(ob)

# Set it's location to 0
ob.location = (0.0,0.0,0.0)

# Now we make copies and move them
for i in range(8):
bpy.ops.object.select_all(action='DESELECT')
ob = obList[0].name
bpy.ops.object.select_name(name=ob, extend=False)
# Duplicate the currently active object and make the new one active
bpy.ops.object.duplicate(linked=False)

# Get the new duplicated object
ob = bpy.context.active_object

# Add this object to the list
obList.append(ob)

# Set the new object's location... well this is a hacky one...
#ob.location = (i,0.0,0.0)

if i == 0:
ob.location = (-span,span,0.0)
operation1()
elif i == 1:
ob.location = (0.0,span,0.0)
operation2()
elif i == 2:
ob.location = (span,span,0.0)
operation3()
elif i == 3:
ob.location = (-span,0.0,0.0)
operation4()
elif i == 4:
ob.location = (span,0.0,0.0)
operation5()
elif i == 5:
ob.location = (-span,-span,0.0)
operation6()
elif i == 6:
ob.location = (0.0,-span,0.0)
operation7()
elif i == 7:
ob.location = (span,-span,0.0)
operation8()

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

# Print out the list of objects
print('obList is now', obList)

#Now you want to grow/ generate something so you can loop through the list
for i, ob in enumerate(obList):

print(i, ob.name)

# Set pivot to individuals
def setPivotIndi():
bpy.context.space_data.pivot_point = 'INDIVIDUAL_ORIGINS'

# Set pivot to boundingbox
def setPivotBBox():
bpy.context.space_data.pivot_point = 'BOUNDING_BOX_CENTER'

# op.1
def operation1():
setPivotIndi()
ob = bpy.context.active_object
bpy.ops.object.vertex_group_remove(all=False)
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[2] < -0.5:
# 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.extrude_faces_move(MESH_OT_extrude={"type":'REGION'}, TRANSFORM_OT_shrink_fatten={"value":-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=(0.5, 0.5, 0.5), constraint_axis=(False, False, False), constraint_orientation='GLOBAL', 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), texture_space=False, release_confirm=False)

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

# op.2
def operation2():
setPivotIndi()
ob = bpy.context.active_object
bpy.ops.object.vertex_group_remove(all=False)
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[0] > 0.5 or f.center[0] < -0.5):
# 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.extrude_faces_move(MESH_OT_extrude={"type":'REGION'}, TRANSFORM_OT_shrink_fatten={"value":-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=(0.5, 0.5, 0.5), constraint_axis=(False, False, False), constraint_orientation='GLOBAL', 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), texture_space=False, release_confirm=False)

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

# op.3
def operation3():
setPivotIndi()
ob = bpy.context.active_object
bpy.ops.object.vertex_group_remove(all=False)
newGroup = ob.vertex_groups.new('vGroup')
bpy.ops.object.mode_set(mode='OBJECT')

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

# See if the current face's centre is above 0.0 on the Z axis
if i % 3 == 0:
# 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.extrude_faces_move(MESH_OT_extrude={"type":'REGION'}, TRANSFORM_OT_shrink_fatten={"value":-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=(0.5, 0.5, 0.5), constraint_axis=(False, False, False), constraint_orientation='GLOBAL', 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), texture_space=False, release_confirm=False)

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

# op.4
def operation4():
setPivotIndi()
ob = bpy.context.active_object
bpy.ops.object.vertex_group_remove(all=False)
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[2] < -0.5:
# 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.extrude_region_move(MESH_OT_extrude={"type":'REGION'}, TRANSFORM_OT_translate={"value":(-0.5, -0.5, -0.5), "constraint_axis":(False, False, True), "constraint_orientation":'NORMAL', "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), "texture_space":False, "release_confirm":False})

bpy.ops.transform.resize(value=(0.5, 0.5, 0.5), constraint_axis=(False, False, False), constraint_orientation='GLOBAL', 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), texture_space=False, release_confirm=False)

bpy.ops.object.mode_set(mode='OBJECT')
# op.5
def operation5():
setPivotIndi()
ob = bpy.context.active_object

# Extrude selected faces already

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.extrude_faces_move(MESH_OT_extrude={"type":'REGION'}, TRANSFORM_OT_shrink_fatten={"value":-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=(0.5, 0.5, 0.5), constraint_axis=(False, False, False), constraint_orientation='GLOBAL', 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), texture_space=False, release_confirm=False)

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

# op.6
def operation6():
setPivotBBox()

ob = bpy.context.active_object
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='TOGGLE')
bpy.ops.mesh.select_all(action='TOGGLE')
bpy.ops.transform.rotate(value=(1.5708,), axis=(-0, -0, -1), constraint_axis=(False, False, False), constraint_orientation='GLOBAL', 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.object.mode_set(mode='OBJECT')

# op.7
def operation7():
setPivotBBox()

ob = bpy.context.active_object
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='TOGGLE')
bpy.ops.mesh.select_all(action='TOGGLE')
bpy.ops.transform.rotate(value=(1.5708,), axis=(-0, -1, 0), constraint_axis=(False, False, False), constraint_orientation='GLOBAL', 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.object.mode_set(mode='OBJECT')

# op.8
def operation8():
bpy.ops.object.modifier_add(type='SUBSURF')
bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Subsurf")

addFirstCube()

if __name__ == '__main__':

register()
  1. # First import bpy to get access to well... everything in blender
  2. from bpy import *
  3. import bpy
  4. #import math, mathutils, random
  5.  
  6. span = 10
  7. scale = 0.5
  8.  
  9. class GMP_Panel(bpy.types.Panel):
  10.         bl_label = "Generative Modeling"
  11.         bl_space_type = "VIEW_3D"
  12.         bl_region_type = "TOOLS"
  13.        
  14.         def draw(self, context):
  15.                 layout = self.layout
  16.                
  17.                 scn = bpy.context.scene
  18.                
  19.                 row = layout.row()
  20.                 row.operator( "bpt.generate_op" )
  21.                 row = layout.row()
  22.                 row.operator( "bpt.reset_op" )
  23.                
  24. class GMP_Operator(bpy.types.Operator):
  25.         bl_idname = "bpt.generate_op"
  26.         bl_label = "Generate Variation"
  27.  
  28.         def execute(self, context):
  29.                 # Do 8 operations
  30.                 clearAndSetNewObj()
  31.                
  32.                 return {'FINISHED'}
  33.                
  34. class GMP_Reset(bpy.types.Operator):
  35.         bl_idname = "bpt.reset_op"
  36.         bl_label = "Reset"
  37.  
  38.         def execute(self, context):
  39.                 # Reset
  40.                 resetNewObj()
  41.                
  42.                 return {'FINISHED'}
  43.  
  44. def register():
  45.         bpy.utils.register_class( GMP_Operator )
  46.         bpy.utils.register_class( GMP_Reset )
  47.         bpy.utils.register_class( GMP_Panel )
  48.  
  49. def unregister():
  50.         bpy.utils.register_class( GMP_Operator )
  51.         bpy.utils.register_class( GMP_Reset )
  52.         bpy.utils.register_class( GMP_Panel )
  53.  
  54. # Reset Object
  55. def resetNewObj():
  56.         bpy.ops.object.select_all(action='SELECT')
  57.         bpy.ops.object.delete()
  58.         addFirstCube()
  59.  
  60. # Add first cube
  61. def addFirstCube():
  62.         bpy.ops.mesh.primitive_cube_add(view_align=False, enter_editmode=False, location=(0, 0, 0), rotation=(0, 0, 0), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))
  63.  
  64.         # Add first vGroup
  65.         ob = bpy.context.active_object
  66.         newGroup = ob.vertex_groups.new('vGroup')
  67.  
  68. # clearAndSetNewObj
  69. def clearAndSetNewObj():
  70.         bpy.ops.object.select_inverse()
  71.         bpy.ops.object.delete()
  72.         bpy.ops.object.select_all(action='SELECT')
  73.        
  74.         # Move Selected Object to Center(0, 0, 0) ------------------
  75.         # So we make a list of all objects we're currently working with
  76.         obList = []
  77.  
  78.         # First get the active object
  79.         ob = bpy.context.active_object
  80.  
  81.         # Add this object to the list
  82.         obList.append(ob)
  83.  
  84.         # Set it's location to 0
  85.         ob.location = (0.0,0.0,0.0)
  86.  
  87.         # Now we make copies and move them
  88.         for i in range(8):
  89.                 bpy.ops.object.select_all(action='DESELECT')
  90.                 ob = obList[0].name
  91.                 bpy.ops.object.select_name(name=ob, extend=False)
  92.                 # Duplicate the currently active object and make the new one active
  93.                 bpy.ops.object.duplicate(linked=False)
  94.        
  95.                 # Get the new duplicated object
  96.                 ob = bpy.context.active_object
  97.  
  98.                 # Add this object to the list
  99.                 obList.append(ob)
  100.  
  101.                 # Set the new object's location... well this is a hacky one...
  102.                 #ob.location = (i,0.0,0.0)
  103.                
  104.                 if i == 0:
  105.                         ob.location = (-span,span,0.0)
  106.                         operation1()
  107.                 elif i == 1:
  108.                         ob.location = (0.0,span,0.0)
  109.                         operation2()
  110.                 elif i == 2:
  111.                         ob.location = (span,span,0.0)
  112.                         operation3()
  113.                 elif i == 3:
  114.                         ob.location = (-span,0.0,0.0)
  115.                         operation4()
  116.                 elif i == 4:
  117.                         ob.location = (span,0.0,0.0)
  118.                         operation5()
  119.                 elif i == 5:
  120.                         ob.location = (-span,-span,0.0)
  121.                         operation6()
  122.                 elif i == 6:
  123.                         ob.location = (0.0,-span,0.0)
  124.                         operation7()
  125.                 elif i == 7:
  126.                         ob.location = (span,-span,0.0)
  127.                         operation8()
  128.        
  129.         bpy.ops.object.select_all(action='DESELECT')
  130.        
  131.         # Print out the list of objects
  132.         print('obList is now', obList)
  133.  
  134.         #Now you want to grow/ generate something so you can loop through the list
  135.         for i, ob in enumerate(obList):
  136.  
  137.                 print(i, ob.name)
  138.        
  139. # Set pivot to individuals
  140. def setPivotIndi():
  141.         bpy.context.space_data.pivot_point = 'INDIVIDUAL_ORIGINS'
  142.        
  143. # Set pivot to boundingbox
  144. def setPivotBBox():
  145.         bpy.context.space_data.pivot_point = 'BOUNDING_BOX_CENTER'
  146.        
  147. # op.1
  148. def operation1():
  149.         setPivotIndi()
  150.         ob = bpy.context.active_object
  151.         bpy.ops.object.vertex_group_remove(all=False)
  152.         newGroup = ob.vertex_groups.new('vGroup')
  153.         bpy.ops.object.mode_set(mode='OBJECT')
  154.        
  155.         # Lets loop through all the faces in the mesh
  156.         for f in ob.data.faces:
  157.        
  158.                 # See if the current face's centre is above 0.0 on the Z axis
  159.                 if f.center[2] < -0.5:
  160.                         # Set select to true
  161.                         f.select = True
  162.                 else:
  163.                         f.select = False
  164.                
  165.         bpy.ops.object.mode_set(mode='EDIT')                   
  166.         bpy.ops.object.vertex_group_set_active(group='vGroup')
  167.         bpy.ops.object.vertex_group_assign(new=False)
  168.         bpy.ops.mesh.extrude_faces_move(MESH_OT_extrude={"type":'REGION'}, TRANSFORM_OT_shrink_fatten={"value":-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})
  169.        
  170.         bpy.ops.transform.resize(value=(0.5, 0.5, 0.5), constraint_axis=(False, False, False), constraint_orientation='GLOBAL', 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), texture_space=False, release_confirm=False)
  171.  
  172.         bpy.ops.object.mode_set(mode='OBJECT')
  173.                
  174. # op.2
  175. def operation2():
  176.         setPivotIndi()
  177.         ob = bpy.context.active_object
  178.         bpy.ops.object.vertex_group_remove(all=False)
  179.         newGroup = ob.vertex_groups.new('vGroup')
  180.         bpy.ops.object.mode_set(mode='OBJECT')
  181.        
  182.         # Lets loop through all the faces in the mesh
  183.         for f in ob.data.faces:
  184.        
  185.                 # See if the current face's centre is above 0.0 on the Z axis
  186.                 if (f.center[0] > 0.5 or f.center[0] < -0.5):
  187.                         # Set select to true
  188.                         f.select = True
  189.                 else:
  190.                         f.select = False
  191.                
  192.         bpy.ops.object.mode_set(mode='EDIT')                   
  193.         bpy.ops.object.vertex_group_set_active(group='vGroup')
  194.         bpy.ops.object.vertex_group_assign(new=False)
  195.         bpy.ops.mesh.extrude_faces_move(MESH_OT_extrude={"type":'REGION'}, TRANSFORM_OT_shrink_fatten={"value":-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})
  196.        
  197.         bpy.ops.transform.resize(value=(0.5, 0.5, 0.5), constraint_axis=(False, False, False), constraint_orientation='GLOBAL', 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), texture_space=False, release_confirm=False)
  198.  
  199.         bpy.ops.object.mode_set(mode='OBJECT')
  200.  
  201. # op.3
  202. def operation3():
  203.         setPivotIndi()
  204.         ob = bpy.context.active_object
  205.         bpy.ops.object.vertex_group_remove(all=False)
  206.         newGroup = ob.vertex_groups.new('vGroup')
  207.         bpy.ops.object.mode_set(mode='OBJECT')
  208.        
  209.         # Lets loop through all the faces in the mesh
  210.         for i, f in enumerate(ob.data.faces):
  211.        
  212.                 # See if the current face's centre is above 0.0 on the Z axis
  213.                 if i % 3 == 0:
  214.                         # Set select to true
  215.                         f.select = True
  216.                 else:
  217.                         f.select = False
  218.                
  219.         bpy.ops.object.mode_set(mode='EDIT')                   
  220.         bpy.ops.object.vertex_group_set_active(group='vGroup')
  221.         bpy.ops.object.vertex_group_assign(new=False)
  222.         bpy.ops.mesh.extrude_faces_move(MESH_OT_extrude={"type":'REGION'}, TRANSFORM_OT_shrink_fatten={"value":-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})
  223.        
  224.         bpy.ops.transform.resize(value=(0.5, 0.5, 0.5), constraint_axis=(False, False, False), constraint_orientation='GLOBAL', 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), texture_space=False, release_confirm=False)
  225.  
  226.         bpy.ops.object.mode_set(mode='OBJECT')
  227.        
  228. # op.4
  229. def operation4():
  230.         setPivotIndi()
  231.         ob = bpy.context.active_object
  232.         bpy.ops.object.vertex_group_remove(all=False)
  233.         newGroup = ob.vertex_groups.new('vGroup')
  234.         bpy.ops.object.mode_set(mode='OBJECT')
  235.        
  236.         # Lets loop through all the faces in the mesh
  237.         for f in ob.data.faces:
  238.        
  239.                 # See if the current face's centre is above 0.0 on the Z axis
  240.                 if f.center[2] < -0.5:
  241.                         # Set select to true
  242.                         f.select = True
  243.                 else:
  244.                         f.select = False
  245.                
  246.         bpy.ops.object.mode_set(mode='EDIT')                   
  247.         bpy.ops.object.vertex_group_set_active(group='vGroup')
  248.         bpy.ops.object.vertex_group_assign(new=False)
  249.         bpy.ops.mesh.extrude_region_move(MESH_OT_extrude={"type":'REGION'}, TRANSFORM_OT_translate={"value":(-0.5, -0.5, -0.5), "constraint_axis":(False, False, True), "constraint_orientation":'NORMAL', "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), "texture_space":False, "release_confirm":False})
  250.        
  251.         bpy.ops.transform.resize(value=(0.5, 0.5, 0.5), constraint_axis=(False, False, False), constraint_orientation='GLOBAL', 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), texture_space=False, release_confirm=False)
  252.  
  253.         bpy.ops.object.mode_set(mode='OBJECT')
  254. # op.5
  255. def operation5():
  256.         setPivotIndi()
  257.         ob = bpy.context.active_object
  258.        
  259.         # Extrude selected faces already
  260.                
  261.         bpy.ops.object.mode_set(mode='EDIT')                   
  262.         bpy.ops.object.vertex_group_set_active(group='vGroup')
  263.         bpy.ops.object.vertex_group_assign(new=False)
  264.         bpy.ops.mesh.extrude_faces_move(MESH_OT_extrude={"type":'REGION'}, TRANSFORM_OT_shrink_fatten={"value":-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})
  265.        
  266.         bpy.ops.transform.resize(value=(0.5, 0.5, 0.5), constraint_axis=(False, False, False), constraint_orientation='GLOBAL', 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), texture_space=False, release_confirm=False)
  267.  
  268.         bpy.ops.object.mode_set(mode='OBJECT')
  269.        
  270. # op.6
  271. def operation6():
  272.         setPivotBBox()
  273.  
  274.         ob = bpy.context.active_object
  275.         bpy.ops.object.mode_set(mode='EDIT')
  276.         bpy.ops.mesh.select_all(action='TOGGLE')
  277.         bpy.ops.mesh.select_all(action='TOGGLE')
  278.         bpy.ops.transform.rotate(value=(1.5708,), axis=(-0, -0, -1), constraint_axis=(False, False, False), constraint_orientation='GLOBAL', 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)
  279.  
  280.         bpy.ops.object.mode_set(mode='OBJECT')
  281.        
  282. # op.7
  283. def operation7():
  284.         setPivotBBox()
  285.  
  286.         ob = bpy.context.active_object
  287.         bpy.ops.object.mode_set(mode='EDIT')
  288.         bpy.ops.mesh.select_all(action='TOGGLE')
  289.         bpy.ops.mesh.select_all(action='TOGGLE')
  290.         bpy.ops.transform.rotate(value=(1.5708,), axis=(-0, -1, 0), constraint_axis=(False, False, False), constraint_orientation='GLOBAL', 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)
  291.  
  292.         bpy.ops.object.mode_set(mode='OBJECT')
  293.        
  294. # op.8
  295. def operation8():
  296.         bpy.ops.object.modifier_add(type='SUBSURF')
  297.         bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Subsurf")
  298.  
  299. addFirstCube()
  300.  
  301. if __name__ == '__main__':
  302.  
  303.         register()
  304.  
go to heaven