Heute mal aus Spaß und Interesse angefangen, mit dem Pythonscripting in Blender 2.61 rumzuspielen. Nach anfänglichen Schwierigkeiten mit den Objektselektoren habe ich dann doch noch ein kleines Script hinbekommen, welches aber doch ein paar grundlegende Aspekte des Scriptings in Blender zeigt.
123456789101112131415161718192021222324252627
#import blender stuffimportbpy#loop through all objects in the scene#bpy.context.scene.objects is a listforobjinbpy.context.scene.objects:#use only real opbject, not the camera or lampifobj.type=='MESH':#select the current objectobj.select=True#remove the current selected object (which will always be obj)bpy.ops.object.delete()#create a new cube objectbpy.ops.mesh.primitive_cube_add(location=(0,0,0))#select this objectobj=bpy.context.scene.objects[0]#move to another locationobj.location=5.0,0.0,0.0print('----------')# print all objectsforobjinbpy.data.objects:print(obj.name)