Hi, so I'm new to maya python and have created a tools that when I pressed the button, that will copy files to destination.
As for more practice and make it cool, I want to create a progress bar when maya doing this work. This things also can let people clear wheter the job has been finished or not.
I don't get how the cmds.progressBar work for this things, and how to put it. Some enlighten would be very appreciated. :)
Because that's leads me to nothing.
This is a copy of my script.
--------------------------------------------------------------------------------------------------------------------------
import maya.cmds as cmds
import os
import shutil
if cmds.window('fileMover', exists=True):
cmds.deleteUI('fileMover', window=True)
folder = os.listdir("B:/PROJECT/JTM03")
ep = []
for item in folder:
if len(item) <= 6:
ep.append(item)
def moveButton(*args):
listItem = cmds.textScrollList( 'scrollList', q=True, si=True)
for item in listItem:
episode = item.split('_')[1]
scene = item.split('_')[2]
shots = item.split('_')[3]
phase = item.split('_')[4]
finalpath = 'B:/PROJECT/JTM03/' + episode + '/' + phase.split('.')[0] + '/'
newFileName = 'JT_' + episode + '_' + scene + '_shot' + shots.split('SH')[1] + '_
ani.ma'
srcfile = finalpath + item
dstdir = 'V:/J_Team/3D/Shots/' + episode + '/' + scene + '/shot'+ shots.split('SH')[1] + '/'
finaldst = 'V:/J_Team/3D/Shots/' + episode + '/' + scene + '/shot'+ shots.split('SH')[1] + '/' + newFileName
if not os.path.exists(dstdir):
os.makedirs(dstdir)
shutil.copy2(srcfile, finaldst)
def printMenu( episodes ):
if cmds.textScrollList('scrollList', exists=True):
cmds.deleteUI('scrollList', control=True)
epFolder = []
directory = os.listdir("B:/PROJECT/JTM03/"+str(episodes)+"/ANM")
for file in directory:
if file.endswith(".ma"):
epFolder.append(file)
cmds.textScrollList( 'scrollList', append=epFolder, ams=True, w=300)
if cmds.button('moveButton', exists=True):
cmds.deleteUI('moveButton', control=True)
cmds.button('moveButton', label='MOVE TO CLIENT FOLDER', w=300, h=50, c=moveButton)
#WINDOW
window = cmds.window('fileMover', title='FILE MOVER', sizeable=False)
cmds.columnLayout()
cmds.optionMenu( label=' EPISODES ', changeCommand=printMenu, w=300, h=40 )
##dropdown menu
for i in range(0,len(ep)):
cmds.menuItem( label = ep[i] )
cmds.showWindow( window )