我正在尝试使用我找到的脚本将phong材质转换为mia材料
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)
我是一个关于mel脚本的完全noob,所以我不知道为什么它不工作或如何解决它 它显示了以下错误:
// 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是我试图转换的材料的名称
答案 0 :(得分:2)
//你需要在某处
定义$ BARKproc connectAndSet(string $original,string $target, $BARK){
// when you call mel function you need to use `
$conn=`connectionInfo -sfd ($BARK)`;
if ($conn!=""){
connectAttr -force $conn $target;
} else {
connectAttr -force $original $target;
disconnectAttr $original $target;
}
}
...
$target=`mrCreateCustomNode -asShader "" mia_material`;
$BARK = "someNode";
connectAndSet($original+".color",$target+".diffuse", $BARK);