Home | Trees | Indices | Help |
|
---|
|
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).
To get a datablock by name you can use dictionary-like syntax.
>>> ob = bpy.data.objects['myobject']
Note that this can only be used for getting.
>>> bpy.data.objects['myobject'] = data # will raise an error
Library distinctions
Blender doesn't allow naming collisions within its own data, but it's possible to run into naming collisions when you have data linked from an external blend file.
You can specify where the data is from by using a (name, library) pair as the key.
>>> group = bpy.data.groups['mygroup', '//mylib.blend'] # only return data linked from mylib
If you want to get a group from the local data only you can use None
>>> group = bpy.data.groups['mygroup', None] # always returns local data
These generic datablocks are sequence datatypes. They are not lists. They support the dictionary and iterator protocols. This implies the following
>>> for me in bpy.data.meshes: ... print me.name
>>> print len(bpy.data.scenes)
>>> ob = bpy.data.objects[-1] # will raise an error
>>> ipo_list = list(bpy.data.ipos)
Instance Methods | |||
datablock |
|
||
None |
|
Instance Variables | |
Datablock or None |
active The active member of the datatype |
Bool |
tag A fast way to set the tag value of every member of the sequence to True or False |
Method Details |
fixme: need description for parameters. This function returns a new datablock containing no data or loaded from a file. Most datatypes accept a name for their argument except for sounds, fonts, ipos and curves that need an additional argument. The name argument is optional if not given a default name will be assigned. The name given may be modified by blender to make it unique. Loading From FileFor images, texts, sounds, fonts types you can use the filename keyword to make a new datablock from a file. New sounds, fonts can only be made with the a filename given. The filename can a keyword or the second argument, use the keyword only for the datablocks new name to be set by the filename. >>> sound = bpy.data.sounds.new('newsound', '~/mysound.wav') # uses the first string given for the name. >>> sound = bpy.data.sounds.new(filename = '~/mysound.wav') # will use the filename to make the name. ImagesImages optionally accept extra 2 arguments for width and height, values between 4 and 5000 if no args are given they will be 256.
>>> img = bpy.data.images.new(name, 512, 512)
CurvesCurves need 2 arguments: bpy.data.curves.new(name, type) type must be one of the following...
>>> text3d = bpy.data.curves.new('MyCurve', 'Text3d') IposIpos need 2 arguments: bpy.data.ipos.new(name, type) type must be one of the following...
Objects cannot be created from bpy.data.objects; objects must be created from the scene. Here are some examples. >>> ob = bpy.data.scenes.active.objects.new('Empty') >>> scn = bpy.data.scenes.active ... ob = sce.objects.new(bpy.data.meshes.new('mymesh'))
|
This function removes a datablock. applies to: Other types will raise an error.
|
Instance Variable Details |
activeThe active member of the datatypeApplies to: This can also be used to set the active data. >>> bpy.data.images.active = bpy.data.images.new(filename = '/home/me/someimage.jpg')
|
tagA fast way to set the tag value of every member of the sequence to True or FalseFor example
>>> bpy.data.meshes.tag = True
Is the same as... >>> for me in bpy.data.meshes: me.tag = True
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0 on Mon Aug 31 23:12:22 2009 | http://epydoc.sourceforge.net |