Module Types
[hide private]
[frames] | no frames]

Source Code for Module Types

 1  # The Blender.Types submodule 
 2   
 3  """ 
 4  The Blender.Types submodule 
 5  =========================== 
 6   
 7  This module is a dictionary of Blender Python types, for type checking. 
 8   
 9  Example:: 
10    import Blender 
11    from Blender import Types, Object, NMesh, Camera, Lamp 
12    # 
13    objs = Object.Get() # a list of all objects in the current scene 
14    for o in objs: 
15      print 
16      print o, type(o) 
17      data = o.getData() 
18      print type(data) 
19      if type(data) == Types.NMeshType: 
20        if len(data.verts): 
21          print "its vertices are obviously of type:", type(data.verts[0]) 
22        print "and its faces:", Types.NMFaceType 
23      elif type(data) == Types.CameraType: 
24        print "It's a Camera." 
25      elif type(data) == Types.LampType: 
26        print "Let there be light!" 
27   
28  Since Blender 2.48a you can get the size of the underlying DNA structs for a collection of Blender Python types. 
29   
30  Example:: 
31    # loop over Types dictionary and print the struct sizes 
32    # -1 where the type is not supported byt the CSizeof function 
33    import Blender.Types as bt 
34    x = dir(bt) 
35    for t in x: 
36      s = 'bt.CSizeof(bt.' + t + ')' 
37      print t,"=", eval(s) 
38   
39  @var ObjectType: Blender Object. The base object, linked to its specific data 
40       at its .data member variable. 
41  @var GroupType: Blender Group. A Group that references a list of objects that are a part of this group. 
42  @var NMeshType: Blender NMesh. The mesh structure. 
43  @var NMFaceType: Blender NMFace. A mesh face, with one (a point), two (an edge), 
44       three (a triangular face) or four (a quad face) vertices. 
45  @var NMVertType: Blender NMVert. A mesh vertex. 
46  @var NMColType: Blender NMCol. A mesh rgba color. 
47  @var MeshType: Blender Mesh. The mesh structure. 
48  @var MFaceType: Blender MFace. A mesh face, with  
49       three (a triangular face) or four (a quad face) vertices. 
50  @var MEdgeType: Blender MEdge. A mesh edge, with two vertices 
51  @var MVertType: Blender MVert. A mesh vertex which wraps a Blender mesh vertex 
52       (typically an object returned from the mesh.verts sequence). 
53  @var PVertType: Blender MVert. A mesh vertex which does not wrap a Blender 
54       mesh vertex (returned from L{Blender.Mesh.MVert()<Mesh.MVert.__init__>}). 
55  @var MColType: Blender MCol. A mesh rgba color. 
56  @var ArmatureType: Blender Armature. The "skeleton", for animating and deforming 
57  objects. 
58  @var BoneType: Blender Bone. Bones are, obviously, the "pieces" of an Armature. 
59  @var EditBoneType: Blender Editbone. Bones in editmode. 
60  @var CurveType: Blender Curve. 
61  @var IpoType: Blender Ipo. 
62  @var CurNurbType: Blender CurNurb. 
63  @var SurfNurbType: Blender SurfNurb. 
64  @var IpoCurveType: Blender IpoCurve. 
65  @var MetaballType: Blender Metaball. 
66  @var CameraType: Blender Camera. 
67  @var ImageType: Blender Image. 
68  @var LampType: Blender Lamp. 
69  @var TextType: Blender Text. 
70  @var Text3dType: Blender Text3d. 
71  @var MaterialType: Blender Material. 
72  @var SceneType: A Blender Scene. Container of all other objects. 
73  @var ButtonType: Blender Button. One of the Draw widgets. 
74  @var vectorType: Blender vector. Used in NMesh, Mesh and elsewhere. 
75  @var matrixType: Blender matrix. 
76  @var quaternionType: Blender quaternion.  Used in armatures. 
77  @var eulerType: Blender euler. 
78  @var bufferType: Blender buffer. A contiguous piece of storage, used in BGL. 
79  @var constantType: Blender constant. A constant dictionary. 
80  @var rgbTupleType: Blender rgbTuple. A (red, green, blue) triplet. 
81  @var TextureType: Blender Texture. 
82  @var MTexType: Blender MTex.  Links materials to a texture. 
83  @var IDGroupType: Blender IDProperty Group type. 
84  @var IDArrayType: Blender IDProperty Array type. 
85  """ 
86   
87 -def CSizeof (type):
88 """ 89 Get the size in bytes of the underlying DNA struct for the given type. 90 @param type: A Blender Python type. 91 @type type: type 92 @return: size in bytes or -1 if not supported type. 93 """
94