如何在不知道约束类型的情况下查询任何约束的目标列表?

发布于 2024-07-17 22:28:54 字数 322 浏览 6 评论 0原文

在 Maya 中,我有一个由以下代码收集的约束列表。 我想迭代约束并查询每个约束的目标:

cons = ls(type='constraint')
for con in cons:
    targets = constraint(query=True, targetList=True)

问题是,没有用于操作所有约束的通用 constraint 命令。 相反,每个约束都有其自己唯一的与其关联的 MEL 命令。

有没有什么方法可以查询约束上的目标,而不必键入检查每个约束并繁琐地运行其各自的 MEL 命令?

In Maya, I have a list of constraints gathered by the following code. I want to iterate the constraints and query the targets for each of them:

cons = ls(type='constraint')
for con in cons:
    targets = constraint(query=True, targetList=True)

The problem, there is no general constraint command for manipulating all constraints. Instead, each constraint has its own unique MEL command associated with it.

Is there any way to query the targets on a constraint without having to type check each constraint and tediously run its respective MEL command?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

罪歌 2024-07-24 22:28:54

.target 上的 listConnections attr

梅尔中的清理:

string $cons[] = `ls -type "constraint"`;
for ( $con in $cons ){
    string $targetAttrString = ( $con+ ".target" );
    string $connections[] = `listConnections $targetAttrString`;
    string $connectionsFlattened[] = stringArrayRemoveDuplicates($connections);
    for ( $f in $connectionsFlattened )
        if ( $f != $con )
            print ( $f+ " is a target\n" );
}

listConnections on the .target attr

the cleanup in mel:

string $cons[] = `ls -type "constraint"`;
for ( $con in $cons ){
    string $targetAttrString = ( $con+ ".target" );
    string $connections[] = `listConnections $targetAttrString`;
    string $connectionsFlattened[] = stringArrayRemoveDuplicates($connections);
    for ( $f in $connectionsFlattened )
        if ( $f != $con )
            print ( $f+ " is a target\n" );
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文