Maya Python中的cmds.scriptCtx到底做什么? [英] What exactly the cmds.scriptCtx in Maya Python does?

查看:163
本文介绍了Maya Python中的cmds.scriptCtx到底做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道cmds.scriptCtx命令到底是做什么的,因为我尝试将其直接从Autodesk帮助页面复制并粘贴到脚本编辑器中,但没有任何反应.这是来自Autodesk帮助的脚本:

I'm wondering what exactly the cmds.scriptCtx command does, cuz I've tried to copy and paste it directly from the Autodesk help page to my script editor and nothing happened. Here's the script from Autodesk help:

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 )

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

I tried select one curve, and two curves, or not selecting anything at all and nothing ever happened. Did I miss something?

我正在为此脚本使用Maya 2018.

I'm using Maya 2018 for this script.

谢谢大家.

推荐答案

我一直想知道这个命令也是什么,但是我从未见过有人使用过它,所以总是以为无视它.

I was always wondering what this command was too, but I've never seen another person use it so always ended up ignoring it.

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

Don't feel bad for not getting it, the documentation does a god awful job explaining how the example works. I had to dig around to find out that it completely omits that you need to use cmds.setToolTo().

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

Create 2 curves, run this, then pick a curve one at a time:

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 取消它.所有的masks参数都在那里,因此您可以限制用户可以选择的对象类型.

So basically, it's an object picker. When you run it, the cursor changes and it displays instructions for the user. In this example, it says pick 2 curves. When you pick one, the instructions update to say pick another curve. When another curve is picked, a script runs to attach both curves. The user can also hit esc at anytime to cancel it. All the masks parameters are there so that you can limit what type of objects the user can pick.

来自3dsMax,这实际上很棒,但是实现起来感觉很差.对于用户来说,这个选择器正在发生根本不是显而易见的.无论如何,这些说明都不是彩色的,在Maya界面的底角很容易错过.您也不能从大纲视图中选择一个对象,这是很可笑的糟糕设计.据我了解,它仅支持MEL.

Coming from 3dsMax this is actually pretty awesome but the implementation feels poor. It's not obvious at all to the user that this picker is happening. The instructions aren't colored in anyway and it's easily missed in the bottom corner of Maya's interface. You also can't pick an object from the outliner, which is ridiculously bad design. And as far as I understand it only supports MEL.

知道这很酷,但是我仍然不认为我会使用它.

It's kind of cool to know, but I still don't think I'll be using it.

这篇关于Maya Python中的cmds.scriptCtx到底做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆