I am trying to convert a phong material to mia material using this script i found
proc connectAndSet(string $original,string $target){
$conn=connectionInfo -sfd ($BARK3);
if ($conn!=""){
connectAttr -force $conn $target;
} else {
connectAttr -force $original $target;
disconnectAttr $original $target;
}
}
proc convertPhongToMia(string $original){
$target=`mrCreateCustomNode -asShader "" mia_material`;
connectAndSet($original+".color",$target+".diffuse");
$sg=`connectionInfo -dfs ($original+".outColor")`;
if ($sg[0]!=""){
$sgr=`match "[^.]*" ((string)$sg[0])`;
connectAttr -force ($target+".outValue") ($sgr+".miMaterialShader");
connectAttr -force ($target+".outValue") ($sgr+".miPhotonShader");
connectAttr -force ($target+".outValue") ($sgr+".miShadowShader");
}
delete $original;
rename $target $original;
}
for ($item in`ls -et phong`)
convertPhongToMia($item)
I am a total noob on mel scripting so i have no idea why its not working or how to fix it it is showing the folowing errors:
// Error: $conn=connectionInfo -sfd ($BARK3); //
// Error: Line 2.24: Invalid use of Maya object "connectionInfo". //
// Error: $conn=connectionInfo -sfd ($BARK3); //
// Error: Line 2.36: "$BARK3" is an undeclared variable. //
// Error: if ($conn!=""){ //
// Error: Line 3.13: "$conn" is an undeclared variable. //
// Error: connectAttr -force $conn $target; //
// Error: Line 4.36: "$conn" is an undeclared variable.
$BARK3 is the name of the material im trying to convert
// you need to define $BARK some where
....