Maya 2015 场景有动画时加速导出的建议
Maya 2015 Suggestions for speeding up exporting when scene has animation
我可以使用自定义文件转换器从 Maya 2015 导出每帧对象数据。
当我从场景中导出动画时,我的导出器会沿着每一帧移动时间滑块,并为动画通道写出新值(例如位置)。这对所有动画通道重复,直到我们到达最后一个动画帧。
以这种方式导出会导致 Maya 的视口更新每一帧。在导出过程中,我真的 want/need 不会发生这种情况。
有谁知道在 Maya 中更新每帧所有逻辑数据而不请求视口也反映这些更新的方法吗?
您正在寻找的关闭视口的关键函数是:
from maya import mel
mel.eval("paneLayout -e -manage false $gMainPane")
打开它:
mel.eval("paneLayout -e -manage true $gMainPane")
其中 $gMainPane
是包含视口路径的 mel 全局变量。
When running a process that loops through the scene frames, like bake
animation or export geo, Maya will update the viewport per frame. This
update is redundant and will slow the process down. So to avoid that,
we can turn off the viewport while the code is running.
# -----------------------------------------------------------------------------
# Imports
# -----------------------------------------------------------------------------
from functools import wraps
from maya import cmds
from maya import mel
# -----------------------------------------------------------------------------
# Decorators
# -----------------------------------------------------------------------------
def viewportOff( func ):
"""
Decorator - turn off Maya display while func is running.
if func will fail, the error will be raised after.
"""
@wraps(func)
def wrap( *args, **kwargs ):
# Turn $gMainPane Off:
mel.eval("paneLayout -e -manage false $gMainPane")
# Decorator will try/except running the function.
# But it will always turn on the viewport at the end.
# In case the function failed, it will prevent leaving maya viewport off.
try:
return func( *args, **kwargs )
except Exception:
raise # will raise original error
finally:
mel.eval("paneLayout -e -manage true $gMainPane")
return wrap
# -----------------------------------------------------------------------------
# Export/Bake function
# -----------------------------------------------------------------------------
@viewportOff
def export():
"""
the export/bake process
"""
# do something
print "running some process"
for i in range(1000):
print i
export()
关闭视口是一种选择,但使用刷新会快 10 倍。
cmds.refresh(suspend=True)
doYourFunc()
cmds.refresh(suspend=False)
我可以使用自定义文件转换器从 Maya 2015 导出每帧对象数据。
当我从场景中导出动画时,我的导出器会沿着每一帧移动时间滑块,并为动画通道写出新值(例如位置)。这对所有动画通道重复,直到我们到达最后一个动画帧。
以这种方式导出会导致 Maya 的视口更新每一帧。在导出过程中,我真的 want/need 不会发生这种情况。
有谁知道在 Maya 中更新每帧所有逻辑数据而不请求视口也反映这些更新的方法吗?
您正在寻找的关闭视口的关键函数是:
from maya import mel
mel.eval("paneLayout -e -manage false $gMainPane")
打开它:
mel.eval("paneLayout -e -manage true $gMainPane")
其中 $gMainPane
是包含视口路径的 mel 全局变量。
When running a process that loops through the scene frames, like bake animation or export geo, Maya will update the viewport per frame. This update is redundant and will slow the process down. So to avoid that, we can turn off the viewport while the code is running.
# -----------------------------------------------------------------------------
# Imports
# -----------------------------------------------------------------------------
from functools import wraps
from maya import cmds
from maya import mel
# -----------------------------------------------------------------------------
# Decorators
# -----------------------------------------------------------------------------
def viewportOff( func ):
"""
Decorator - turn off Maya display while func is running.
if func will fail, the error will be raised after.
"""
@wraps(func)
def wrap( *args, **kwargs ):
# Turn $gMainPane Off:
mel.eval("paneLayout -e -manage false $gMainPane")
# Decorator will try/except running the function.
# But it will always turn on the viewport at the end.
# In case the function failed, it will prevent leaving maya viewport off.
try:
return func( *args, **kwargs )
except Exception:
raise # will raise original error
finally:
mel.eval("paneLayout -e -manage true $gMainPane")
return wrap
# -----------------------------------------------------------------------------
# Export/Bake function
# -----------------------------------------------------------------------------
@viewportOff
def export():
"""
the export/bake process
"""
# do something
print "running some process"
for i in range(1000):
print i
export()
关闭视口是一种选择,但使用刷新会快 10 倍。
cmds.refresh(suspend=True)
doYourFunc()
cmds.refresh(suspend=False)