正如标题所述,我在Maya中有一个简单的python脚本无法运行。在
import maya.cmds as cmds
import maya.mel as mel
def createCylinder():
# Check if cylinder "trunkCylinder" exists. Delete it
if cmds.objExists("trunkCylinder"):
cmds.delete("trunkCylinder")
# Create a new cylinder called "trunkCylinder"
cmds.polyCylinder(axis=(0,1,0), height=1, name="trunkCylinder" )
# Clear the selection, then select the cap and invert the selection.
cmds.select(clear=True)
cmds.select("trunkCylinder.f[21]", replace=True)
invertedSel = mel.eval("invertSelection;")
print str(invertedSel)
# ^^ Prints: None ^^
# End result is nothing is selected
createCylinder()
我希望玛雅打印出一个除了f[21]以外的所有面,并在视口中反转选择。相反,它返回None并取消选择f[21]。有人看到我的代码有错误吗,或者我没有正确地使用反向选择?在
幸运的是,我可以选择f[0:20]作为解决方案,甚至可以获得一个面列表并将其与我的面列表进行比较,从而删除两个列表中的任何内容。然而,我已经可以预见到让反向选择工作将节省我很多时间的情况。如有任何帮助,我们将不胜感激。在
下面的Python脚本绝对可以使用。你应该试试看)。星号用于选择数组中的所有其他面,以及
toggle
标志,它为您反转了一个选择。在相关问题 更多 >
编程相关推荐