4 Name: 'Batch Object Name Edit'
7 Tooltip: 'Apply the chosen rule to rename all selected objects at once.'
12 # --------------------------------------------------------------------------
13 # Batch Name Edit by Campbell Barton (AKA Ideasman)
14 # --------------------------------------------------------------------------
15 # ***** BEGIN GPL LICENSE BLOCK *****
17 # This program is free software; you can redistribute it and/or
18 # modify it under the terms of the GNU General Public License
19 # as published by the Free Software Foundation; either version 2
20 # of the License, or (at your option) any later version.
22 # This program is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 # GNU General Public License for more details.
27 # You should have received a copy of the GNU General Public License
28 # along with this program; if not, write to the Free Software Foundation,
29 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 # ***** END GPL LICENCE BLOCK *****
32 # --------------------------------------------------------------------------
37 replace = Draw.PupStrInput('replace: ', '', 32)
38 if replace == None: return
40 with = Draw.PupStrInput('with: ', '', 32)
41 if with == None: return
43 for ob in Object.GetSelected():
45 if replace in ob.name:
46 chIdx = ob.name.index(replace)
48 # Remove the offending word and replace it with - 'with'
49 ob.name = ob.name[ :chIdx] + with + ob.name[chIdx + len(replace):]
53 prefix = Draw.PupStrInput('prefix: ', '', 32)
54 if prefix == None: return
56 for ob in Object.GetSelected():
57 ob.name = prefix + ob.name
61 suffix = Draw.PupStrInput('suffix: ', '', 32)
62 if suffix == None: return
64 for ob in Object.GetSelected():
65 ob.name = ob.name + suffix
68 truncate = Draw.PupIntInput('truncate start: ', 0, 0, 31)
70 for ob in Object.GetSelected():
71 ob.name = ob.name[truncate: ]
74 truncate = Draw.PupIntInput('truncate end: ', 0, 0, 31)
75 if truncate == None: return
77 for ob in Object.GetSelected():
78 ob.name = ob.name[ :-truncate]
83 name = "Selected Object Names%t|Replace Text|Add Prefix|Add Suffix|Truncate Start|Truncate End"
84 result = Draw.PupMenu(name)