Discussion:
[Maya-Python] how to make a progress bar that show Maya are working on it
Yoga Yasahardja
2018-08-06 11:46:16 UTC
Permalink
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. :)

I also didn't get what is this and how to use it (found in this forum) :
gMainProgressBar = maya.mel.eval('$tmp = $gMainProgressBar')

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 )
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/ad067fbd-317d-43f1-8088-e8eace0eb7db%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Virbhadra Gupta
2018-08-06 17:14:02 UTC
Permalink
First you need to import

import maya.mel as mel

and your moveButton function will look like this

def moveButton(*args):
listItem = cmds.textScrollList( 'scrollList', q=True, si=True)
# accessing maya Main progreas bar
bar_name = mel.eval('$tmp = $gMainProgressBar')
# creating bar
cmds.progressBar(bar_name, e=True, bp=True, ii=True, status='"Your
Message...', max=len(listItem))
barCount=0
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)
# adding progress in bar
cmds.progressBar(bar_name, edit=True, step=barCount)
barCount+=1
# Ending bar
cmds.progressBar(bar_name, edit=True, endProgress=True)
Post by Yoga Yasahardja
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. :)
gMainProgressBar = maya.mel.eval('$tmp = $gMainProgressBar')
Because that's leads me to nothing.
This is a copy of my script.
--------------------------------------------------------------------------------------------------------------------------
import maya.cmds as cmds
import os
import shutil
cmds.deleteUI('fileMover', window=True)
folder = os.listdir("B:/PROJECT/JTM03")
ep = []
ep.append(item)
listItem = cmds.textScrollList( 'scrollList', q=True, si=True)
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
os.makedirs(dstdir)
shutil.copy2(srcfile, finaldst)
cmds.deleteUI('scrollList', control=True)
epFolder = []
directory = os.listdir("B:/PROJECT/JTM03/"+str(episodes)+"/ANM")
epFolder.append(file)
cmds.textScrollList( 'scrollList', append=epFolder, ams=True, w=300)
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
cmds.menuItem( label = ep[i] )
cmds.showWindow( window )
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/b30e50a3-0f8a-40cb-b4d7-e5a96e685af9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Yoga Yasahardja
2018-08-07 03:37:42 UTC
Permalink
That's not working as I want. But thankyou bro.. I'll try to combine it
with this one I found :
I think the key is I have to put my task into maxlimit and right now I'm
thinking to solve it.
Thanks for enlighting me up!


def progress():

cmds.progressWindow(title='Progress Bar', progress=0, status='Progress
: 0%%', isInterruptable=False)
limit = 1000000
step = 1
for i in xrange(limit):
progress = 100.0 / limit * i
if progress % step:
continue
cmds.progressWindow(e=True, progress=progress, status='Creating
Directory : %d%%' % progress)

cmds.progressWindow(endProgress=True)

cmds.progressWindow(title='Progress Bar', progress=0, status='Progress
: 0%%', isInterruptable=False)
for i in xrange(limit):
progress = 100.0 / limit * i
if progress % step:
continue
cmds.progressWindow(e=True, progress=progress, status='Copying
Files : %d%%' % progress)

cmds.progressWindow(endProgress=True)

progress()
message = cmds.confirmDialog(message="Successfully Copied! ", ma =
'left', icn='information')
Post by Virbhadra Gupta
First you need to import
import maya.mel as mel
and your moveButton function will look like this
listItem = cmds.textScrollList( 'scrollList', q=True, si=True)
# accessing maya Main progreas bar
bar_name = mel.eval('$tmp = $gMainProgressBar')
# creating bar
cmds.progressBar(bar_name, e=True, bp=True, ii=True, status='"Your
Message...', max=len(listItem))
barCount=0
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
os.makedirs(dstdir)
shutil.copy2(srcfile, finaldst)
# adding progress in bar
cmds.progressBar(bar_name, edit=True, step=barCount)
barCount+=1
# Ending bar
cmds.progressBar(bar_name, edit=True, endProgress=True)
Post by Yoga Yasahardja
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. :)
gMainProgressBar = maya.mel.eval('$tmp = $gMainProgressBar')
Because that's leads me to nothing.
This is a copy of my script.
--------------------------------------------------------------------------------------------------------------------------
import maya.cmds as cmds
import os
import shutil
cmds.deleteUI('fileMover', window=True)
folder = os.listdir("B:/PROJECT/JTM03")
ep = []
ep.append(item)
listItem = cmds.textScrollList( 'scrollList', q=True, si=True)
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
os.makedirs(dstdir)
shutil.copy2(srcfile, finaldst)
cmds.deleteUI('scrollList', control=True)
epFolder = []
directory = os.listdir("B:/PROJECT/JTM03/"+str(episodes)+"/ANM")
epFolder.append(file)
cmds.textScrollList( 'scrollList', append=epFolder, ams=True, w=300)
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
cmds.menuItem( label = ep[i] )
cmds.showWindow( window )
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/861bde57-d736-47fc-b5a9-222f3bb43da1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Virbhadra Gupta
2018-08-07 05:21:05 UTC
Permalink
Sure buddy i just give you example how you can use it.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/db54bb44-82d8-45b0-a074-3c5bd798d0b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...