1
2
3 """
4 The Blender.Group submodule.
5
6 Group
7 =====
8
9 This module provides access to B{Group} data in Blender.
10
11 Example::
12
13 # Make Dupli's Real, as a python script.
14
15 from Blender import *
16
17 scn= Scene.GetCurrent()
18 for ob in scn.objects:
19 print 'Object Group Settings'
20 print ob.name, ob.type
21 print 'enableDupVerts:', ob.enableDupVerts
22 print 'enableDupFrames:', ob.enableDupFrames
23 print 'enableDupGroup:', ob.enableDupGroup
24 print 'DupGroup:', ob.DupGroup
25 dupe_obs= ob.DupObjects
26 print 'num dup obs:', len(dupe_obs)
27
28 for dup_ob, dup_matrix in dupe_obs:
29 print '\tDupOb', dup_ob.name
30 scn.objects.new(dup_ob.data)
31 new_ob.setMatrix(dup_matrix)
32 new_ob.sel= 1 # select all real instances.
33
34 ob.sel=0 # Desel the original object
35
36 Window.RedrawAll()
37
38 Example::
39
40 # Make a new group with the selected objects, and add an instance of this group.
41
42 from Blender import *
43
44 scn= Scene.GetCurrent()
45
46 # New Group
47 grp= Group.New('mygroup')
48 grp.objects= scn.objects
49
50 # Instance the group at an empty using dupligroups
51 ob= scn.objects.new(None)
52 ob.enableDupGroup= True
53 ob.DupGroup= grp
54 Window.RedrawAll()
55
56
57 Example::
58
59 # Remove all non mesh objects from a group.
60
61 from Blender import *
62
63 scn= Scene.GetCurrent()
64
65 # New Group
66 grp= Group.Get('mygroup')
67 for ob in list(grp.objects): # Convert to a list before looping because we are removing items
68 if ob.type != 'Mesh':
69 grp.objects.unlink(ob)
70 """
71
72 -def New (name = None):
73 """
74 Make a new empty group, name optional, default is "Group"
75 @type name: string
76 @param name: The name of the new group.
77 @rtype: Blender Group
78 @return: A Empty Blender Group object
79 """
80
81 -def Get (name = None):
82 """
83 Get the Group object(s) from Blender.
84 @type name: string
85 @param name: The name of the Group object.
86 @rtype: Blender Group or a list of Blender Groups
87 @return: It depends on the I{name} parameter:
88 - (name): The Group object called I{name}, Exception if it is not found.
89 - (): A list with all Group objects in the current blend file.
90 """
91
93 """
94 Unlink (delete) this group from Blender.
95 @Note: No objects will be removed, just the group that references them.
96 @type group: group
97 @param group: A group to remove from this blend file, does not remove objects that this group uses.
98 """
99
100
102 """
103 The Group object
104 ================
105 This object gives access to Groups in Blender.
106 @ivar layers: Layer bitmask for this group.
107 @type layers: int
108 @ivar objects: Objects that this group uses.
109 This is a sequence with-list like access so use list(grp.objects) if you need to use a list (where grp is a group).
110 The groups objects can be set by assigning a list or iterator of objects to the groups objects.
111 objects.link() and objects.unlink() also work with the the objects iterator just like with lists.
112
113 B{Note}: append() and remove() have been deprecated and replaced by link() and unlink(),
114 after Blender 2.43 append() and remove() will not be available.
115 @type objects: custom object sequence
116 """
117
119 """
120 Make a copy of this group
121 @rtype: Group
122 @return: a copy of this group
123 """
125 """
126 Make a copy of this group
127 @rtype: Group
128 @return: a copy of this group
129 """
130
131 import id_generics
132 Group.__doc__ += id_generics.attributes
133