BPython:
- fixing bug reported by Paolo Colombo: space handler slinks set for a 3d view were not set when the area got maximized; - Blender.Object: added object.isSB() method to know if an object is a soft body (has ob->soft != NULL). Used in fixfromarmature.py. Scripts: - updates: batch_name_edit (Campbell), fixfromarmature (JMS); - additions: X3D exporter by Bart; Envelope Suite by Jonas Petersen; BVH 2 Armature by Jean-Baptiste Perin; Camera Changer by Regis Montoya (3R); Interactive Console by Campbell (ideasman). - tiny updates in other scripts.
This commit is contained in:
@@ -50,74 +50,82 @@ menu of the 3d View.
|
||||
|
||||
from Blender import *
|
||||
|
||||
def new():
|
||||
newname = Draw.PupStrInput('Name: ', '', 32)
|
||||
if newname == None: return
|
||||
for ob in Object.GetSelected():
|
||||
ob.name = newname
|
||||
|
||||
def replace():
|
||||
replace = Draw.PupStrInput('Replace: ', '', 32)
|
||||
if replace == None: return
|
||||
|
||||
with = Draw.PupStrInput('With: ', '', 32)
|
||||
if with == None: return
|
||||
|
||||
for ob in Object.GetSelected():
|
||||
|
||||
if replace in ob.name:
|
||||
chIdx = ob.name.index(replace)
|
||||
|
||||
# Remove the offending word and replace it with - 'with'
|
||||
ob.name = ob.name[ :chIdx] + with + ob.name[chIdx + len(replace):]
|
||||
|
||||
|
||||
def prefix():
|
||||
prefix = Draw.PupStrInput('prefix: ', '', 32)
|
||||
if prefix == None: return
|
||||
|
||||
for ob in Object.GetSelected():
|
||||
ob.name = prefix + ob.name
|
||||
|
||||
|
||||
def suffix():
|
||||
suffix = Draw.PupStrInput('Suffix: ', '', 32)
|
||||
if suffix == None: return
|
||||
|
||||
for ob in Object.GetSelected():
|
||||
ob.name = ob.name + suffix
|
||||
|
||||
def truncate_start():
|
||||
truncate = Draw.PupIntInput('Truncate Start: ', 0, 0, 31)
|
||||
if truncate != None:
|
||||
def main():
|
||||
def new():
|
||||
newname = Draw.PupStrInput('Name: ', '', 32)
|
||||
if newname == None: return
|
||||
Window.WaitCursor(1)
|
||||
for ob in Object.GetSelected():
|
||||
ob.name = ob.name[truncate: ]
|
||||
|
||||
def truncate_end():
|
||||
truncate = Draw.PupIntInput('Truncate End: ', 0, 0, 31)
|
||||
if truncate == None: return
|
||||
ob.name = newname
|
||||
|
||||
def replace():
|
||||
replace = Draw.PupStrInput('Replace: ', '', 32)
|
||||
if replace == None: return
|
||||
with = Draw.PupStrInput('With: ', '', 32)
|
||||
if with == None: return
|
||||
Window.WaitCursor(1)
|
||||
for ob in Object.GetSelected():
|
||||
ob.name = ob.name.replace(replace, with)
|
||||
|
||||
# Use pythons replace, its better.
|
||||
'''
|
||||
if replace in ob.name:
|
||||
chIdx = ob.name.index(replace)
|
||||
|
||||
# Remove the offending word and replace it with - 'with'
|
||||
ob.name = ob.name[ :chIdx] + with + ob.name[chIdx + len(replace):]
|
||||
'''
|
||||
|
||||
|
||||
for ob in Object.GetSelected():
|
||||
ob.name = ob.name[ :-truncate]
|
||||
|
||||
|
||||
|
||||
|
||||
name = "Selected Object Names%t|New Name|Replace Text|Add Prefix|Add Suffix|Truncate Start|Truncate End"
|
||||
result = Draw.PupMenu(name)
|
||||
|
||||
if result == -1:
|
||||
pass
|
||||
elif result == 1:
|
||||
new()
|
||||
elif result == 2:
|
||||
replace()
|
||||
elif result == 3:
|
||||
prefix()
|
||||
elif result == 4:
|
||||
suffix()
|
||||
elif result == 5:
|
||||
truncate_start()
|
||||
elif result == 6:
|
||||
truncate_end()
|
||||
def prefix():
|
||||
prefix = Draw.PupStrInput('prefix: ', '', 32)
|
||||
|
||||
if prefix == None: return
|
||||
Window.WaitCursor(1)
|
||||
for ob in Object.GetSelected():
|
||||
ob.name = prefix + ob.name
|
||||
|
||||
|
||||
def suffix():
|
||||
suffix = Draw.PupStrInput('Suffix: ', '', 32)
|
||||
if suffix == None: return
|
||||
Window.WaitCursor(1)
|
||||
for ob in Object.GetSelected():
|
||||
ob.name = ob.name + suffix
|
||||
|
||||
def truncate_start():
|
||||
truncate = Draw.PupIntInput('Truncate Start: ', 0, 0, 31)
|
||||
if truncate != None:
|
||||
Window.WaitCursor(1)
|
||||
for ob in Object.GetSelected():
|
||||
ob.name = ob.name[truncate: ]
|
||||
|
||||
def truncate_end():
|
||||
truncate = Draw.PupIntInput('Truncate End: ', 0, 0, 31)
|
||||
if truncate == None: return
|
||||
Window.WaitCursor(1)
|
||||
for ob in Object.GetSelected():
|
||||
ob.name = ob.name[ :-truncate]
|
||||
|
||||
|
||||
name = "Selected Object Names%t|New Name|Replace Text|Add Prefix|Add Suffix|Truncate Start|Truncate End"
|
||||
result = Draw.PupMenu(name)
|
||||
|
||||
if result == -1:
|
||||
pass
|
||||
elif result == 1:
|
||||
new()
|
||||
elif result == 2:
|
||||
replace()
|
||||
elif result == 3:
|
||||
prefix()
|
||||
elif result == 4:
|
||||
suffix()
|
||||
elif result == 5:
|
||||
truncate_start()
|
||||
elif result == 6:
|
||||
truncate_end()
|
||||
|
||||
Window.WaitCursor(0)
|
||||
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user