向场景中的引用添加多个代理

问题描述 投票:0回答:1

我只想知道如何在Maya场景中为引用文件添加多个代理。

场景:我们选择包含“_v001”的对象:

select -r "*_v001";

我们创建函数来为每个引用的文件添加代理:

global proc proxyAddition() {

    string $selectionList[] = `ls -sl`;

    if(size($selectionList)) {

        string $object = $selectionList[0];
        string $currentRN = `referenceQuery -rfn $object`;
        string $currentFilePath = `referenceQuery -filename $object`;
        string $currentNamespace = `referenceQuery -namespace $object`;

        if(endsWith($currentRN, "v001RN") == 1) {

            string $newRN = `substitute "v001RN" $currentRN "v002"`;
            string $newFilePath = `substitute "v001" $currentFilePath "v002"`;
            string $newNamespace = `substitute "v001" $currentNamespace "v002"`;
            proxyAdd $currentRN $newFilePath "HD";
            print "Opération effectuée avec succès.";
        }
    } else {
        warning "Aucun objet de type v001 dans la scène.";
    }
}
proxyAddition;

我想要的是在每个引用的文件中找到字符串“v001”并将其更改为“v002”(对于proxyName,命名空间和文件路径)。

谢谢。

file reference proxy maya mel
1个回答
1
投票

最后我成功完成了它:

select -r "*_v001:*";

global proc proxyAddition() {

    string $selectionList[] = `ls -sl -type "mesh"`;

    if(size($selectionList)) {

        for($object in $selectionList) {

            string $currentRN = `referenceQuery -rfn $object`;
            string $currentFilePath = `referenceQuery -filename $object`;
            string $currentNamespace = `referenceQuery -namespace $object`;

            if(endsWith($currentRN, "v001RN") == 1) {

                string $newRN = `substitute "v001RN" $currentRN "v002"`;
                string $newFilePath = `substitute "v001" $currentFilePath "v002"`;
                string $newNamespace = `substitute "v001" $currentNamespace "v002"`;
                proxyAdd $currentRN $newFilePath "HD";
                print "Opération effectuée avec succès.";               
            }
        }
    } else {
        warning "Aucun objet de type v001 dans la scène.";
    }
}
proxyAddition;

该脚本选择名称包含“_v001”的对象,然后对其进行过滤以仅保留网格对象。之后,我们使用referenceQuery方法来存储当前的引用变量。然后我们将包含“v001”字符串值的变量替换为新变量中的“v002”。此替换方法用于当前引用对象的文件路径,命名空间和ReferenceNode。使用这些新变量,我们可以使用“proxyAdd”添加新的代理/代理。

只有在同一文件夹中有参考文件时,此过程才有效。如果不是这种情况,请使用替换方法为您的filepath var提供更多选项。您还可以使用自己的值更改“v001”和“v002”,这些值区分您的参考文件版本。

“HD”参数用于参考文件的proxyTag。

© www.soinside.com 2019 - 2024. All rights reserved.