【问题标题】:Converting a string into a command using Pymel使用 Pymel 将字符串转换为命令
【发布时间】:2013-07-04 02:14:46
【问题描述】:
我目前有一个字符串列表,需要在其中转换为命令。
IE:
"checkerText.outAlpha" needs to be checkerText.outAlpha
有没有将字符串转换为pymel命令的命令?
我需要这个,所以我可以将两个着色器连接在一起。
IE:
'checkerText.outAlpha' >> 'layText.inputs[0].alpha'
needs to be
checkerText.outAlpha >> layText.inputs[0].alpha
【问题讨论】:
标签:
arrays
string
list
command
pymel
【解决方案1】:
特别是对于 layeredTexture 节点,inputs 属性实际上是一个 pymel 方法,因此它返回所述节点的输入节点。为了达到所需的结果,您必须通过 pymel 的 Attribute() 类显式声明“layeredTexture1.inputs[1].alpha”作为属性,或者通过 pymel 必须提供的名为 PyNode() 的非常方便的命令传递它,它确实你想要的那种。 This 应该为您提供有关 PyNodes 的所有信息。这一切的一些例子是:
PyNode("checker1").outAlpha >> PyNode("layeredTexture1.inputs[1].alpha") # The whole attr needs to be in the string because of the above explenation.
Attribute("checker1.outAlpha") >> Attribute("layeredTexture1.inputs[1].alpha")
首选使用 PyNode,但您可以同时使用这两种方法。