Custom progress reporting for maya commands

138 views
Skip to first unread message

Alex Rideout

unread,
Aug 20, 2015, 3:50:47 PM8/20/15
to Python Programming for Autodesk Maya
Hey all,

I am curious if there is a way that one can display the progress of some built in maya commands that don't output this information by default. Some of maya's commands have either progress bars or print out current completion status information, but there are plenty that don't that could benefit from it if you are sending large amounts of data through them and have no way of gauging how long it will take.

Primarily, I am looking for a way to track the progress of writing out cache files for dynamics especially in the cases of running a command line Maya instance. Currently I can look at output cache files to see what frames have been cached out, though it would be nice to see this in an output window. I looked into scriptJobs utilizing timeChanged events in hopes that as the cache function changes time in maya, that these script jobs would trigger (no such luck). Any ideas?

Alex

Justin Israel

unread,
Aug 20, 2015, 5:57:28 PM8/20/15
to python_in...@googlegroups.com
I don't think there is a reliable way to assume what the internal implementation is doing for any Maya command (such as assuming the time callbacks might fire).  If a particular Maya command blocks the main thread for a while and does a lot of work with not much feedback, I would think your only course of action is what you had mentioned... to externally monitor the effects of its progress. You could wrap the command and pop up your own progress output.
 

Alex

--
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/6062e220-eed6-488f-8916-488e25d5ab5a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ravi Jagannadhan

unread,
Aug 20, 2015, 6:02:39 PM8/20/15
to python_in...@googlegroups.com
Is there a particular workflow whose progress you're trying to measure?


For more options, visit https://groups.google.com/d/optout.



--
Where we have strong emotions, we're liable to fool ourselves - Carl Sagan

Colas Fiszman

unread,
Aug 21, 2015, 5:10:20 AM8/21/15
to python_in...@googlegroups.com
Hi Alex,
One solution to print some custom info on cache progression with maya in command line is to create a expression that will call a mel or python function that will print whatever info you want.
Greets,
Colas

--

Marcus Ottosson

unread,
Aug 21, 2015, 5:46:06 AM8/21/15
to python_in...@googlegroups.com

For every function? I don’t think so, as it depends on what the function is doing.

For example, consider this.

def cache():
  count = 10
  while True:
    count -= 1
    if count < 0:
      break

This would run until done, and there’s no way to determine how long it will take unless you knew the source.

For some functions, such as Maya’s geometry caching? Maybe, if it got implemented that way. I’d think that if it visually moves the timeline, there must be a way, however hacky. Otherwise you’re at the mercy of whatever notification mechanism got built into the function to start with.

subscribers = []

def cache():
  count = 10
  while True:
    for func in subscribers:
      func("%i loops left" % count)
    count -= 1
    if count < 0:
      break

def update_my_widget(status):
  # widget.setText(status)
  print(status)

subscribers.append(update_my_widget)

cache()


For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Message has been deleted

Alex Rideout

unread,
Aug 21, 2015, 10:38:55 AM8/21/15
to Python Programming for Autodesk Maya
For some functions, as they operate on large numbers of objects can be wrapped in another iterative function to give you the ability to provide progress.

def centerPivots():
    sel
=pm.ls(sl=1)
    count
=0
    
for obj in sel:
        pm
.makeIdentity(obj,apply=True,t=1,r=0,s=0,n=0,pn=1)
        count
+=1
        
print str(count)+' of '+str(len(sel))


Though unfortunately in the instance of a cache function, it only operates usually on one object and doesn't have any discernible way of catching how far along the progress is. When watching a cache happen in GUI instances, you can see the timeline update as the function goes through. So as Marcus said, I am looking for a kind of hacky way of perhaps utilizing this fact to call functions.

Another hacky way of automatically checking cache progress might be to have a function that checks the cache directory for output files and uses that to show progress.

I have also built a function for printing out to the output window opposed to maya's internal script editor output in hopes to use that for writing out messages (for purposes of seeing progress during command line operation and as a result, farm job reporting).

def printWindow(message):
    mayaOut
=sys.stdout
    sys
.stdout=sys.__stdout__
    
print message
    sys
.stdout=mayaOut

Colas Fiszman

unread,
Aug 21, 2015, 11:43:46 AM8/21/15
to python_in...@googlegroups.com
Using a expression is a hacky way to run a function every time the frame change.
Maya will evaluate the expression at every frame change and you can call your mel or python function from the expression.


2015-08-21 15:37 GMT+01:00 Alex Rideout <alex.r...@gmail.com>:
For some functions, as they operate on large numbers of objects can be wrapped in another iterative function to give you the ability to provide progress.

def centerPivots():
    sel
=pm.ls(sl=1)
    count
=0
   
for obj in sel:

        pm
.makeIdentity(s,apply=True,t=1,r=0,s=0,n=0,pn=1)

        count
+=1
       
print str(count)+' of '+str(len(sel))


Though unfortunately in the instance of a cache function, it only operates usually on one object and doesn't have any discernible way of catching how far along the progress is. When watching a cache happen in GUI instances, you can see the timeline update as the function goes through. So as Marcus said, I am looking for a kind of hacky way of perhaps utilizing this fact to call functions.

Another hacky way of automatically checking cache progress might be to have a function that checks the cache directory for output files and uses that to show progress.

I have also built a function for printing out to the output window opposed to maya's internal script editor output in hopes to use that for writing out messages (for purposes of seeing progress during command line operation and as a result, farm job reporting).

def printWindow(message):
    mayaOut
=sys.stdout
    sys
.stdout=sys.__stdout__
   
print message
    sys
.stdout=mayaOut

--
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.

Alex Rideout

unread,
Aug 21, 2015, 12:02:29 PM8/21/15
to Python Programming for Autodesk Maya
Good call Colas! Sorry I didn't quite understand what you were talking about earlier. This does indeed evaluate upon all frame changes including those during file caches. Now just a matter of writing a function for it to call.
Reply all
Reply to author
Forward
0 new messages