没错,该命令的功能就是File -> Optimize Scene Size
使用pymel
import pymel.core as pm
optimize_scene_options = [
"nurbsSrfOption",
"nurbsCrvOption",
"unusedNurbsSrfOption",
"deformerOption",
"unusedSkinInfsOption",
"poseOption",
"clipOption",
"expressionOption",
"groupIDnOption",
"animationCurveOption",
"shaderOption",
"cachedOption",
"transformOption",
"displayLayerOption",
"renderLayerOption",
"setsOption",
"partitionOption",
"locatorOption",
"ptConOption",
"pbOption",
"snapshotOption",
"unitConversionOption",
"referencedOption",
"brushOption",
"unknownNodesOption",
"shadingNetworksOption",
]
optimize_scene_options=['displayLayerOption']
pm.mel.scOpt_performOneCleanup(optimize_scene_options)
其中optimize_scene_options可以选择自己想要勾选的优化类型。此时执行会弹出确认对话框
如果要不弹出对话框,可以执行如下命令
import os
os.environ["MAYA_TESTING_CLEANUP"] = "1"
注意:
如果要恢复对话框,不能os.environ["MAYA_TESTING_CLEANUP"] = "0"
必须删掉掉这个环境变量
del os.environ["MAYA_TESTING_CLEANUP"]
网友评论