maya Python file writing progress bar ?

921 views
Skip to first unread message

Virbhadra Gupta

unread,
Apr 8, 2017, 9:47:09 AM4/8/17
to Python Programming for Autodesk Maya
here is my code

def exportAnimation():
    dataForJson = getAnimData(startFrame,endFrame)
    path = cmds. internalVar (utd=True)
    filePath = str (path)+'animaton.VGdata'
    exportData = json.dumps ( dataForJson , sort_keys= True , ensure_ascii=True , indent= 2 )
    File = open( filePath, 'w')
    load = File.write (exportData) 
    
    """
    Here i need to create file writing progressBar
    """
    #craete progressBar
    gMainProgressBar = maya.mel.eval('$tmp = $gMainProgressBar')
    
    # need to show progress of writing 
     
    
    File.close()



Justin Israel

unread,
Apr 8, 2017, 5:27:13 PM4/8/17
to Python Programming for Autodesk Maya
Do you only need progress for the act of writing the file? Is the write going to take a while and not the other steps? Any progress bar implementation is going to need you to feed it updated progress values to push it towards 100%. So if this file write really needs a progress bar then you have to split the writes up into chunks. Then you loop over the number of chunks, write the bytes and update the progress bar. 

Is this what you meant? Or did you want progress for the entire set of steps? Can you be more specific about what aspect has you stuck? 





--
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/5603bdc6-6781-402e-a372-8cf4fa496bb8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jesse Kretschmer

unread,
Apr 10, 2017, 3:14:02 PM4/10/17
to Python Programming for Autodesk Maya
From your code the .write(exportData) is going to write all data at once. As Justin pointed out, you'll need to break up the write into smaller pieces so you can increment your progress bar. 

There are plenty of good examples in the world showing progress with python. This one should help:
http://stackoverflow.com/a/15645088/2216741

-j

On Sat, Apr 8, 2017 at 11:27 PM, Justin Israel <justin...@gmail.com> wrote:


On Sun, Apr 9, 2017, 1:47 AM Virbhadra Gupta <viru....@gmail.com> wrote:
here is my code

def exportAnimation():
    dataForJson = getAnimData(startFrame,endFrame)
    path = cmds. internalVar (utd=True)
    filePath = str (path)+'animaton.VGdata'
    exportData = json.dumps ( dataForJson , sort_keys= True , ensure_ascii=True , indent= 2 )
    File = open( filePath, 'w')
    load = File.write (exportData) 
    
    """
    Here i need to create file writing progressBar
    """
    #craete progressBar
    gMainProgressBar = maya.mel.eval('$tmp = $gMainProgressBar')
    
    # need to show progress of writing 
     
    
    File.close()

Do you only need progress for the act of writing the file? Is the write going to take a while and not the other steps? Any progress bar implementation is going to need you to feed it updated progress values to push it towards 100%. So if this file write really needs a progress bar then you have to split the writes up into chunks. Then you loop over the number of chunks, write the bytes and update the progress bar. 

Is this what you meant? Or did you want progress for the entire set of steps? Can you be more specific about what aspect has you stuck? 



--
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+unsubscribe@googlegroups.com.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2jEYV%3D4%3DRuPhkJQ3yJ%2BYKiFveKG7%2Bzo5DnaSCtu-6EYg%40mail.gmail.com.

Virbhadra Gupta

unread,
Apr 11, 2017, 3:43:34 AM4/11/17
to Python Programming for Autodesk Maya
Thank You Justin!!
now i got the point what i need to do :)
thank you for your input :)


On Sunday, April 9, 2017 at 2:57:13 AM UTC+5:30, Justin Israel wrote:


On Sun, Apr 9, 2017, 1:47 AM Virbhadra Gupta <viru....@gmail.com> wrote:
here is my code

def exportAnimation():
    dataForJson = getAnimData(startFrame,endFrame)
    path = cmds. internalVar (utd=True)
    filePath = str (path)+'animaton.VGdata'
    exportData = json.dumps ( dataForJson , sort_keys= True , ensure_ascii=True , indent= 2 )
    File = open( filePath, 'w')
    load = File.write (exportData) 
    
    """
    Here i need to create file writing progressBar
    """
    #craete progressBar
    gMainProgressBar = maya.mel.eval('$tmp = $gMainProgressBar')
    
    # need to show progress of writing 
     
    
    File.close()

Do you only need progress for the act of writing the file? Is the write going to take a while and not the other steps? Any progress bar implementation is going to need you to feed it updated progress values to push it towards 100%. So if this file write really needs a progress bar then you have to split the writes up into chunks. Then you loop over the number of chunks, write the bytes and update the progress bar. 

Is this what you meant? Or did you want progress for the entire set of steps? Can you be more specific about what aspect has you stuck? 





--
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+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages