Scripting mit Blender 2.61 #2
Habe mal den Code vom letzen Blender Post erweitert und etwas Bewegung hinzugefügt. In ein Blender Skript kopieren und im Animationsfenster auf Play drücken.
#import blender stuff
import bpy
#loop through all objects in the scene
#bpy.context.scene.objects is a list
for obj in bpy.context.scene.objects:
#use only real opbject, not the camera or lamp
if obj.type == 'MESH':
#select the current object
obj.select = True
#remove the current selected object (which will always be obj)
bpy.ops.object.delete()
#create a new cube object
bpy.ops.mesh.primitive_cube_add(location=(0, 0, 0))
#define a function which will be called every frame change
def my_func(scene):
obj = scene.objects[0]
obj.location.x = scene.frame_current/50
print("frame #", scene.frame_current)
#remove all handlers
for i in range( len( bpy.app.handlers.frame_change_pre ) ):
bpy.app.handlers.frame_change_pre.pop()
#append handler
bpy.app.handlers.frame_change_pre.append(my_func)