Hi

I'm learning some python, coming from a MEL background [though I'm no 
expert in that either] and I'm trying to write a simple script to rename a 
number of objects according to a user input name. I've got it to work but I 
want it to test if there is no user input and if not [and the user didn't 
press the cancel button] loop back and re-prompt for input.

I was thinking something along the lines of this : 
1 - declare a procedure to do the renaming
2 - prompt dialog
3 - if the input is valid run the procedure, if not pop up a message and 
ask whether to retry or cancel
4 - if retry, run the procedure again

but I came unstuck and I can't find anything to do with declaring a 
procedure in pymel. Can anyone help? Here's what I've written so far. 
Thanks in advance

##############################################################################################################

#get selection

sel=ls(sl=1)

#get user input
input = promptDialog(t='New 
Name',b=['OK','Cancel'],db='OK',cb='Cancel',ds='no input')

#set base number to 1

x=1

#test user input and if not empty string, rename selected objects

if input=='OK':
name=promptDialog(q=1, t=1)
 if len(name) != 0:
for s in sel:
s.rename(name + str(x))
x+=1
else:
#if user has not input a valid string prompt to retry
message = confirmDialog(message ='Please enter a 
name',b=['Retry','Cancel'],db='Retry',cb='Cancel',ds='Cancel')

##############################################################################################################
 

-- 
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe

Reply via email to