【问题标题】:What exactly the cmds.scriptCtx in Maya Python does?Maya Python 中的 cmds.scriptCtx 到底是做什么的?
【发布时间】:2019-10-14 08:54:29
【问题描述】:

我想知道 cmds.scriptCtx 命令究竟是做什么的,因为我尝试将它直接从 Autodesk 帮助页面复制并粘贴到我的脚本编辑器中,但什么也没发生。这是 Autodesk 帮助中的脚本:

import maya.cmds as cmds

cmds.scriptCtx( title='Attach Curve', totalSelectionSets=1, fcs="select -r $Selection1; performAttachCrv 0 \"\"", cumulativeLists=True, expandSelectionList=True, setNoSelectionPrompt='Select two curves close to the attachment points', setSelectionPrompt='Select a second curve close to the attachment point', setDoneSelectionPrompt='Never used because setAutoComplete is set', setAutoToggleSelection=True, setSelectionCount=2, setAutoComplete=True, curveParameterPoint=True )

我尝试选择一条曲线和两条曲线,或者根本不选择任何东西,但什么也没发生。我错过了什么吗?

我正在为这个脚本使用 Maya 2018。

谢谢大家。

【问题讨论】:

    标签: python command maya


    【解决方案1】:

    我也一直想知道这个命令是什么,但我从未见过其他人使用它,所以最后总是忽略它。

    不要因为没有得到它而感到难过,文档在解释示例的工作原理方面做得非常糟糕。我不得不四处寻找发现它完全省略了您需要使用cmds.setToolTo()。

    创建 2 条曲线,运行它,然后一次选择一条曲线:

    import maya.cmds as cmds
    
    picker = cmds.scriptCtx(
        title='Attach Curve', totalSelectionSets=1, fcs="select -r $Selection1; performAttachCrv 0 \"\"", 
        cumulativeLists=True, expandSelectionList=True, setNoSelectionPrompt='Select two curves close to the attachment points', 
        setSelectionPrompt='Select a second curve close to the attachment point', setDoneSelectionPrompt='Never used because setAutoComplete is set', 
        setAutoToggleSelection=True, setSelectionCount=2, setAutoComplete=True, curveParameterPoint=True
    )
    
    
    cmds.setToolTo(picker)
    

    所以基本上,它是一个对象选择器。当你运行它时,光标会改变,它会为用户显示指令。在这个例子中,它说选择 2 条曲线。当您选择一条曲线时,说明会更新为选择另一条曲线。当拾取另一条曲线时,将运行一个脚本来附加两条曲线。用户也可以随时点击 esc 来取消它。所有掩码参数都在那里,以便您可以限制用户可以选择的对象类型。

    来自 3dsMax,这实际上非常棒,但执行起来感觉很糟糕。对于用户来说,这个选择器正在发生并不明显。无论如何,这些说明都没有着色,并且很容易在 Maya 界面的下角遗漏。你也不能从大纲中挑选一个对象,这是非常糟糕的设计。据我了解,它只支持 MEL。

    知道这有点酷,但我仍然认为我不会使用它。

    【讨论】:

    • 啊啊啊啊啊啊!!!!!!说明栏!!!是的,我绝对没有看到即将到来的大声笑=)))))))非常感谢您的解释和您的经验!你帮我摆脱了这种可怕的头痛!!!
    猜你喜欢
    • 2016-07-03
    • 2015-08-06
    • 2013-09-02
    • 2014-01-02
    • 2013-10-10
    • 2017-05-08
    • 2022-01-20
    • 2012-10-17
    • 2017-06-15
    相关资源
    最近更新 更多