I've used this script:
//change all phong Materials to aiStandard Material
// If you need to change another Material, simple change `ls -type "phong"`
{
string $newMaterialType = "aiStandard";
string $nm = `createNode $newMaterialType`;
string $ms[] = `ls -type "blinn"`;
string $pa[] = `listAttr -visible -settable -scalar $ms`;
string $nma[] = `listAttr -visible -settable -scalar $nm`;
string $ca[] = stringArrayRemove($nma, $pa);
$ca = stringArrayRemove($ca, $pa);
delete $nm;
string $a; string $m; float $v; string $cl[];
for ($m in $ms)
{
$nm = `createNode $newMaterialType`;
$cl = `listConnections -destination true -plugs true -source false -type shadingEngine $m`;
connectAttr -f ($nm + ".outColor") ($cl);
for ($a in $ca)
{
$v = `getAttr ($m + "." + $a)`;
catchQuiet(`setAttr ($nm + "." + $a) $v`);
}
delete $m;
}
}to convert a blinn to arnold, and it does work, so i tried the other way:
//change all phong Materials to aiStandard Material
// If you need to change another Material, simple change `ls -type "phong"`
{
string $newMaterialType = "blinn";
string $nm = `createNode $newMaterialType`;
string $ms[] = `ls -type "aiStandard"`;
string $pa[] = `listAttr -visible -settable -scalar $ms`;
string $nma[] = `listAttr -visible -settable -scalar $nm`;
string $ca[] = stringArrayRemove($nma, $pa);
$ca = stringArrayRemove($ca, $pa);
delete $nm;
string $a; string $m; float $v; string $cl[];
for ($m in $ms)
{
$nm = `createNode $newMaterialType`;
$cl = `listConnections -destination true -plugs true -source false -type shadingEngine $m`;
connectAttr -f ($nm + ".outColor") ($cl);
for ($a in $ca)
{
$v = `getAttr ($m + "." + $a)`;
catchQuiet(`setAttr ($nm + "." + $a) $v`);
}
delete $m;
}
}I've also tried "aiStandardSurface" instead of "aiStandard"
But this doesnt work...
i get this error:
// Error: line 18: The destination attribute '' cannot be found. //