progressWindow to tie in for bakeResults

19 views
Skip to first unread message

kiteh

unread,
Oct 1, 2018, 6:19:39 PM10/1/18
to Python Programming for Autodesk Maya
I am trying to make use of `cmds.progressWindow` during my animation baking function.
However, while doing so, it seems that my `cmds.progressWindow` only effects after my `cmds.bakeResults`... There is a window popup however, I am not seeing any gauge...

Or if there is a way that I can still make use of the progressWindow and have it populate by per function?

This is my current code:
def do_bake(self, selections):
    ...
    ...
    cmds.bakeResults(
        (sel_attrs if attr_names else selections),
        hierarchy="both",
        preserveOutsideKeys=True,
        simulation=True,
        time=(init_start, frame_range[1])
    )

    # I tried to do the following
    amount = 0
    for sel in selections:
        if cmds.progressWindow( query=True, isCancelled=True ) :
                break
        # Check if end condition has been reached
        if cmds.progressWindow( query=True, progress=True ) >= 100 :
                break

        amount = amount + 1
        status_msg = "Processing: {0}".format(amount)
        cmds.progressWindow(edit=True, progress=amount, status=status_msg)

    cmds.progressWindow(endProgress=1)


def main():
    cmds.progressWindow(
        title='My Test Window',
        progress=amount,
        status='Processing: 0%',
        isInterruptable=True
    )

    selections = self.check_current_selections()
    parent_constrains = self.do_parent_constrain(selections)
    animation_bake = self.do_bake(selections)



Justin Israel

unread,
Oct 1, 2018, 6:43:25 PM10/1/18
to python_in...@googlegroups.com
The problem is that your cmds.bakeResults() is a blocking call. It won't return until the operation is complete. After that, your progressWindow logic is simply to loop over a list of selections and advance the progress, which is effectively going to be instant, so that isn't a great way to advance the progress. 
The way to use progressWindow is when you have operations that can happen during each loop, or at least some observable state that can change while you are looping. It won't work to check progress after the thing you ran has already finished.

Maybe there is some way to bake in time chunks, as part of your progress loop?


--
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/6e15b594-198d-443b-b1de-384dd8621be6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages