Finally I succeed to finish it :
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;
The script selects object which name contain "_v001", then filters it to keep mesh objects only. After that, we use referenceQuery method to store our current reference variables. Then we substitute variable which contain "v001" string value to "v002" in new variables. This substitute method is used for the filepath, the namespace and the ReferenceNode of our current reference object(s). With these new variables, we can add our new proxy/proxies using "proxyAdd".
This process could work only if you have reference files in the same folder. If it's not the case, use the substitute method to your filepath var with more options. You can also change "v001" and "v002" by your own values which differentiate your references files versions.
The "HD" argument is used for proxyTag of your reference file.