xuv's notebook

Side notes, howtos and random bits of information related to Julien Deswaef's projects

User Tools

Site Tools


workshops:blender:modeling_script

Modeling script

We will go in details over the script pasted here:

extrude.py
import bpy
 
# Get first selected object
ob = bpy.context.active_object
 
# Get the faces of the selected object
faces = ob.data.polygons
 
bpy.ops.object.mode_set(mode = 'EDIT')
bpy.ops.mesh.select_all(action = 'DESELECT')
bpy.ops.object.mode_set(mode = 'OBJECT')
 
print(len(faces))
 
for i in range(len(faces)):
    face = faces[i]
    face.select = True
    bpy.ops.object.mode_set(mode = 'EDIT')
    bpy.ops.mesh.extrude_region_move(TRANSFORM_OT_translate={"value": face.normal, "constraint_orientation" : 'NORMAL' })
    bpy.ops.transform.resize( value=( 0.5, 0.5, 0.5 ), constraint_orientation='LOCAL' )
    bpy.ops.transform.rotate(value=-.5, axis= face.normal)
    bpy.ops.mesh.select_all(action = 'DESELECT')
    bpy.ops.object.mode_set(mode = 'OBJECT')
    face.select = False
workshops/blender/modeling_script.txt · Last modified: 2015/06/20 23:36 by Julien Deswaef