51
51
from Blender import *
54
newname = Draw.PupStrInput('Name: ', '', 32)
55
if newname == None: return
56
for ob in Object.GetSelected():
60
replace = Draw.PupStrInput('Replace: ', '', 32)
61
if replace == None: return
63
with = Draw.PupStrInput('With: ', '', 32)
64
if with == None: return
66
for ob in Object.GetSelected():
68
if replace in ob.name:
69
chIdx = ob.name.index(replace)
71
# Remove the offending word and replace it with - 'with'
72
ob.name = ob.name[ :chIdx] + with + ob.name[chIdx + len(replace):]
76
prefix = Draw.PupStrInput('prefix: ', '', 32)
77
if prefix == None: return
79
for ob in Object.GetSelected():
80
ob.name = prefix + ob.name
84
suffix = Draw.PupStrInput('Suffix: ', '', 32)
85
if suffix == None: return
87
for ob in Object.GetSelected():
88
ob.name = ob.name + suffix
91
truncate = Draw.PupIntInput('Truncate Start: ', 0, 0, 31)
93
for ob in Object.GetSelected():
94
ob.name = ob.name[truncate: ]
97
truncate = Draw.PupIntInput('Truncate End: ', 0, 0, 31)
98
if truncate == None: return
100
for ob in Object.GetSelected():
101
ob.name = ob.name[ :-truncate]
106
name = "Selected Object Names%t|New Name|Replace Text|Add Prefix|Add Suffix|Truncate Start|Truncate End"
107
result = Draw.PupMenu(name)
55
newname = Draw.PupStrInput('Name: ', '', 32)
56
if newname == None: return
58
for ob in Object.GetSelected():
62
replace = Draw.PupStrInput('Replace: ', '', 32)
63
if replace == None: return
64
with = Draw.PupStrInput('With: ', '', 32)
65
if with == None: return
67
for ob in Object.GetSelected():
68
ob.name = ob.name.replace(replace, with)
70
# Use pythons replace, its better.
72
if replace in ob.name:
73
chIdx = ob.name.index(replace)
75
# Remove the offending word and replace it with - 'with'
76
ob.name = ob.name[ :chIdx] + with + ob.name[chIdx + len(replace):]
81
prefix = Draw.PupStrInput('prefix: ', '', 32)
83
if prefix == None: return
85
for ob in Object.GetSelected():
86
ob.name = prefix + ob.name
90
suffix = Draw.PupStrInput('Suffix: ', '', 32)
91
if suffix == None: return
93
for ob in Object.GetSelected():
94
ob.name = ob.name + suffix
97
truncate = Draw.PupIntInput('Truncate Start: ', 0, 0, 31)
100
for ob in Object.GetSelected():
101
ob.name = ob.name[truncate: ]
104
truncate = Draw.PupIntInput('Truncate End: ', 0, 0, 31)
105
if truncate == None: return
107
for ob in Object.GetSelected():
108
ob.name = ob.name[ :-truncate]
111
name = "Selected Object Names%t|New Name|Replace Text|Add Prefix|Add Suffix|Truncate Start|Truncate End"
112
result = Draw.PupMenu(name)