美文网首页Maya开发
Maya优化场景(python)不弹出对话框

Maya优化场景(python)不弹出对话框

作者: MasterZhang | 来源:发表于2021-05-06 09:24 被阅读0次

    没错,该命令的功能就是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"]
    

    相关文章

      网友评论

        本文标题:Maya优化场景(python)不弹出对话框

        本文链接:https://www.haomeiwen.com/subject/ggprdltx.html