[PYTHON] Technique to stop drawing the screen and reduce the waiting time for baking

at first

This article is the 12th day article of Maya Advent Calendar 2019.

In CG animation production, a barren waiting time of waiting for a bake occurs in every process. This time, I will introduce a technique to reduce the waiting time for baking work as much as possible.

Overall flow

Stop drawing the screen in Maya. ↓ Make heavy processing. ↓ Resume screen drawing in Maya and check the result.

It will be the flow.

How to stop drawing on the screen

Here are three ways to stop drawing screens in Maya.

Stop drawing the screen from the UI (Maya 2017 ~)

Stop drawing (UI)

To stop drawing the screen from the UI, press the stop button surrounded by a red frame. image.png

Drawing stopped (UI)

When executed, the work screen will be surrounded by a red frame. Drawing on the Maya screen will stop while this red frame appears. image.png

Resume drawing (UI)

Press the stop button again to resume drawing on the screen. image.png

Stop drawing the screen from the command (ogs command / Maya2017 ~)

You can stop drawing with the pause flag of the ogs command.

Stop drawing (ogs command)

Execute the following command to stop drawing the screen. The screen will be surrounded by a red line as you did from the UI.

cmds.ogs(pause=True)

Resume drawing (ogs command)

Use the same command to resume drawing.

cmds.ogs(pause=True)

Before maya2017 ...

This feature cannot be used because the pause flag does not exist in the ogs command prior to Maya 2017.

http://help.autodesk.com/cloudhelp/2015/JPN/Maya-Tech-Docs/CommandsPython/ogs.html image.png

Usage example (ogs command)

When processing to bake from 1 to 1000 frames, write as follows.

#Stop drawing
cmds.ogs(pause=True)

#Bake processing
cmds.bakeResults( bakenodes, t=(1,1000), simulation=True )

#Resume drawing
cmds.ogs(pause=True)

Stop drawing the screen from the command (refresh command / Maya2011 ~)

The one I use most often

Stop drawing (refresh command)

Execute the following command to stop drawing the screen. The red frame is not displayed on the screen like the ogs command. It just freezes the screen.

cmds.refresh(suspend=True)

Resume drawing (refresh command)

Use the same command to resume drawing.

cmds.refresh(suspend=False)

Usage example (refresh command)

When processing to bake from 1 to 1000 frames, write as follows.

#Stop drawing
cmds.refresh(suspend=True)

#Bake processing
cmds.bakeResults( bakenodes, t=(1,1000), simulation=True )

#Resume drawing
cmds.refresh(suspend=False)

Comparison of processing speed between drawing stopped state and drawing state

I would like to measure the time required for baking when the screen is stopped / drawing is not stopped. Let's compare each of maya2019 / maya2018 / maya2017 / maya2015.

Data to use

Measure the time it takes to bake a simple Hair simulation. Bake range is from 1 to 1000F. The total number of Joints to bake is 91. Maya's evaluation mode is fixed at DG. bake.gif

Script to use

How to not stop drawing

"""
How to not stop drawing
"""
import time
#Start measurement
start = time.time()

#Bake processing
bakenode = cmds.ls('bake_joint*')
cmds.bakeResults( bakenode, t=(1,1000), simulation=True )

#End of measurement
elapsed_time = time.time() - start
print (u"processing time:{0}".format(elapsed_time) + "[sec]")

How to stop drawing using the ogs command

"""
How to stop drawing using the ogs command
"""
import time
#Start measurement
start = time.time()

#Stop drawing
cmds.ogs(pause=True)

#Bake processing
bakenode = cmds.ls('bake_joint*')
cmds.bakeResults( bakenode, t=(1,1000), simulation=True )

#Resume drawing
cmds.ogs(pause=True)

#End of measurement
elapsed_time = time.time() - start
print (u"processing time:{0}".format(elapsed_time) + "[sec]")

How to stop drawing using the refresh command

"""
How to stop drawing using the refresh command
"""
import time
#Start measurement
start = time.time()

#Stop drawing
cmds.refresh(suspend=True)

#Bake processing
bakenode = cmds.ls('bake_joint*')
cmds.bakeResults( bakenode, t=(1,1000), simulation=True )

#Resume drawing
cmds.refresh(suspend=False)

#End of measurement
elapsed_time = time.time() - start
print (u"processing time:{0}".format(elapsed_time) + "[sec]")

Measurement result

Addition: The measurement result in parallel mode has been added.

Open the verification data created in Maya 2019.2 in each version and measure. Measured in DG mode and parallel mode. Stop screen drawing when using ogs command and refresh command

▼ Evaluation mode DG

Maya Bake as it is ogs command refresh command
maya2019 60.34s 32.31s 43.90s
maya2018 59.15s 31.56s 45.97s
maya2017 55.93s 25.34s 31.18s
maya2016 51.18s None 20.76s
maya2015 47.82s None 17.21s

▼ Evaluation mode parallel

Maya Bake as it is ogs command refresh command
maya2019 17.34s 15.80s 14.87s
maya2018 18.78s 16.17s 19.69s
maya2017 16.84s 13.92s 12.94s
maya2016 46.50s None 20.14s
maya2015 None None None

The parallel mode is pretty good! Also, the processing speed is faster if you stop drawing the screen for both DG / parallel.

According to my personal rule of thumb, this speed difference increases as the amount of data handled increases. If it takes 10 minutes to bake, it will take about 2 minutes ...!

Other uses

Besides baking animations Screen drawing stop is also effective when outputting the geometry cache and saving the simulation cache.

Finally

Use your time meaningfully!

Recommended Posts

Technique to stop drawing the screen and reduce the waiting time for baking
Try posting to Qiita for the first time
Molecular dynamics simulation to try for the time being
"Stop committing Japanese files to git on Mac> <" For the time being, I wrote a script to search for incompatible Japanese files on Mac and Linux.
Tips for Python beginners to use the Scikit-image example for themselves 8 Processing time measurement and profiler
[python] How to use the library Matplotlib for drawing graphs
wxPython: Draw animation and graph drawing at the same time
I want to move selenium for the time being [for mac]
I tried to illustrate the time and time in C language
I tried to display the time and today's weather w
[Introduction to Reinforcement Learning] Reinforcement learning to try moving for the time being
I want to create a Dockerfile for the time being.
The story of returning to the front line for the first time in 5 years and refactoring Python Django
Kaggle for the first time (kaggle ①)
Kaguru for the first time
I want to record the execution time and keep a log.
Java programmer tried to touch Go language (for the time being)
For the time being, I want to convert files with ffmpeg !!
[Pepper Demo Tips] A technique for quickly installing and withdrawing Pepper before and after the demo to minimize unnecessary noise.