Home | Trees | Indices | Help |
|
---|
|
# apply the active image to the active mesh # this script has no error checking to keep it small and readable. sce= bpy.data.scenes.active ob_act = sce.objects.active # assuming we have an active, might be None me = ob_act.getData(mesh=1) # assuming a mesh type, could be any img = bpy.data.images.active # assuming we have an active image for f in me.faces: f.image = img Window.RedrawAll()Example:
# make a new object from an existing mesh # and make it active scn= bpy.data.scenes.active me = bpy.data.meshes['mymesh'] ob = sce.objects.new(me) # new object from the mesh sce.objects.active = obExample:
# print the names of any non local objects sce= bpy.data.scenes.active for ob in sce.objects: if ob.lib: print 'external object:', ob.name, ob.libExample:
# add an empty object at each vertex of the active mesh scn= bpy.data.scenes.active ob_act = sce.objects.active matrix = ob_act.matrixWorld me = ob_act.getData(mesh=1) for v in me.verts: ob = sce.objects.new('Empty') ob.loc = v.co * matrix # transform the vertex location by the objects matrix.Example:
# load all the wave sound files in a directory import os sound_dir = '/home/me/soundfiles/' sounds_new = [] for fname in os.listdir(sound_dir): if fname.lower().endswith('.wav'): try: snd = bpy.data.sounds.new(filename = sound_dir + fname) except: snd = None if snd: sounds_new.append(snd) # Print the sounds for snd in sounds_new: print sndExample:
# apply a new image to each selected mesh object as a texface. width, height= 512, 512 scn= bpy.data.scenes.active for ob in sce.objects.context: if not ob.lib and ob.type == 'Mesh': # object isn't from a library and is a mesh me = ob.getData(mesh=1) me.faceUV = True # add UV coords and textures if we don't have them. # Make an image named after the mesh img = bpy.data.images.new(me.name, width, height) for f in me.faces: f.image = img Window.RedrawAll()
Classes | |
libBlockSeq This provides a unified way to access and manipulate data types in Blender (scene, object, mesh, curve, metaball, material, texture, image, lattice, lamp, camera, ipo, world, font, text, sound, groups, armatures, actions). |
Variables | |
libBlockSeq |
actions sequence for action data |
libBlockSeq |
armatures sequence for armature data |
libBlockSeq |
cameras sequence for camera data |
libBlockSeq |
curves sequence for curve data, used to store Curve, Surface and Text3d data. |
libBlockSeq |
fonts sequence for font data |
libBlockSeq |
groups sequence for group data |
libBlockSeq |
images sequence for image data |
libBlockSeq |
ipos sequence for ipo data |
libBlockSeq |
lamps sequence for lamp data |
libBlockSeq |
lattices sequence for lattice data |
libBlockSeq |
materials sequence for material data |
libBlockSeq |
meshes sequence for mesh data |
libBlockSeq |
metaballs sequence for metaball data |
libBlockSeq |
objects sequence for object data |
libBlockSeq |
scenes sequence for scene data |
libBlockSeq |
sounds sequence for sound data |
libBlockSeq |
texts sequence for text data |
libBlockSeq |
textures sequence for texture data |
libBlockSeq |
worlds sequence for world data |
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Mon May 19 15:32:19 2008 | http://epydoc.sourceforge.net |