4
Name: 'Selection to DupliGroup'
7
Tooltip: 'Turn the selection into a dupliGroup using the active objects transformation, objects are moved into a new scene'
14
# ***** BEGIN GPL LICENSE BLOCK *****
16
# Script copyright (C) Campbell Barton
18
# This program is free software; you can redistribute it and/or
19
# modify it under the terms of the GNU General Public License
20
# as published by the Free Software Foundation; either version 2
21
# of the License, or (at your option) any later version.
23
# This program is distributed in the hope that it will be useful,
24
# but WITHOUT ANY WARRANTY; without even the implied warranty of
25
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26
# GNU General Public License for more details.
28
# You should have received a copy of the GNU General Public License
29
# along with this program; if not, write to the Free Software Foundation,
30
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32
# ***** END GPL LICENCE BLOCK *****
33
# --------------------------------------------------------------------------
39
scn = Scene.GetCurrent()
40
ob_act = scn.objects.active
43
Draw.PupMenu('Error%t|No active object')
45
dup_name = ob_act.name
47
obsel = list(scn.objects.context)
53
if not parent.sel or parent not in obsel:
54
Draw.PupMenu('Error%t|Objects "'+ob.name+'" parent "'+parent.name+'" is not in the selection')
57
mat_act = ob_act.matrixWorld
60
grp = Group.New(dup_name)
63
# Create the new empty object to be the dupli
64
ob_dup = scn.objects.new('Empty')
65
ob_dup.setMatrix(mat_act)
66
ob_dup.name = dup_name + '_dup'
68
ob_dup.enableDupGroup = True
71
scn_new = Scene.New(dup_name)
73
# Transform the objects to remove the active objects matrix.
74
mat_act_inv = mat_act.copy().invert()
77
ob.setMatrix(ob.matrixWorld * mat_act_inv)
79
scn_new.objects.link(ob)
80
scn.objects.unlink(ob)
83
if __name__ == '__main__':