<p>根据您要查找的内容,<code>cmds.listHistory</code>或{<cd2>}将告诉您给定节点的内容。<code>listHistory</code>仅限于驱动形状节点更改的可能连接的子集,因此如果您对约束感兴趣,则需要遍历节点的<code>listConnections</code>,并查看上游的内容。这个列表可以任意大,因为它可能包含许多隐藏的节点,比如单元转换、组部件等等,而这些都是您可能不想关心的。在</p>
<p>这里有一个简单的方法来控制一个节点的传入连接并得到一个传入连接的树:</p>
<pre><code>def input_tree(root_node):
visited = set() # so we don't get into loops
# recursively extract input connections
def upstream(node, depth = 0):
if node not in visited:
visited.add(node)
children = cmds.listConnections(node, s=True, d=False)
if children:
grandparents = ()
for history_node in children:
grandparents += (tuple(d for d in upstream(history_node, depth + 1)))
yield node, tuple((g for g in grandparents if len(g)))
# unfold the recursive generation of the tree
tree_iter = tuple((i for i in upstream(root_node)))
# return the grandparent array of the first node
return tree_iter[0][-1]
</code></pre>
<p>它应该生成一个嵌套的输入连接列表,比如</p>
^{pr2}$
<p>其中每个级别都包含一个输入列表。然后你可以浏览一下,看看你提议的变更是否包括这个项目。在</p>
<p>然而,这个<em>不会告诉您连接是否会导致真正的循环:这取决于不同节点内的数据流。一旦你确定了可能的循环,你就可以回去看看这个循环是真的(比如两个影响彼此翻译的项目)还是无害的(我影响你的旋转,你影响我的翻译)。在</p>