到底是什么cmds.scriptCtx在玛雅Python是什么?

2024-04-26 14:10:34 发布

您现在位置:Python中文网/ 问答频道 /正文

我想知道到底是什么原因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来编写这个脚本。你知道吗

谢谢你们。你知道吗


Tags: theto命令脚本truecloseattachment粘贴
1条回答
网友
1楼 · 发布于 2024-04-26 14:10:34

我也一直在想这个命令是什么,但我从来没有见过其他人使用它,所以总是忽略它。你知道吗

不要为没有得到它而感到难过,文档做了一个非常糟糕的工作来解释这个例子是如何工作的。我不得不仔细研究,发现它完全忽略了需要使用cmds.setToolTo()。你知道吗

创建两条曲线,运行此操作,然后一次拾取一条曲线:

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参数都在那里,因此您可以限制用户可以选择的对象类型。你知道吗

来自3dsMax这实际上是相当可怕的,但实现感觉很差。对于用户来说,这个picker正在发生一点也不明显。这些指令无论如何都不会着色,而且很容易在Maya界面的下角丢失。你也不能从大纲视图中选择一个对象,这是非常糟糕的设计。据我所知,它只支持梅尔。你知道吗

知道有点酷,但我还是不认为我会用它。你知道吗

相关问题 更多 >