Phlok
05-12-2009, 04:00 PM
I wrote a script that dynamically creates expressions, unfortunately I always get a
Error: Illegal attribute in expression: GObject10
message. I have been trying things for hours, now but I can't figure out what's going wrong there- maybe you can help.
Here's the code. The first three strings are for debugging, GObject10 is a group, containing objects and it is connected to a shader named "SShadeGObject10"
string $item = "GObject10";
string $grp = "GObject10";
string $aux = "\"SShade\"";
string $content =
"int $moCheck; \r\n"+
"$moCheck = `getAttr " + $item + ".translateX" + " ` ; \r\n"+
"int $iter; \r\n"+
"if($moCheck != 0)"+
"{ \r\n"+
"$iter = `getAttr " + $item + ".iterations" + " ` ; \r\n"+
"enlightenIt(" + $item +" ); \r\n"+
"$iter += $iter; \r\n" +
"setAttr " + $item + ".iterations " + " $iter;"+
"}\r\n" +
"if($iter == 10)"+
"{ \r\n" +
" expression -s \" \" $item; \r\n" +
"} \r\n" +
"proc enlightenIt(string $grp){ \r\n"+
"string $mat = (" + $aux + "+ $grp); \r\n"+
"vector $col = `getAttr ($mat + \".outColor\")` ; \r\n" +
"vector $col1 = <<$col.x + 0.1, $col.y + 0.1, $col.z + 0.1>>; \r\n" +
"setAttr ($mat + \".outColor\") ($col1.x) ($col1.y) ($col1.z); \r\n"+
"}";
expression -s $content $item;
I can do all the "getAttr GObject10.outColor" or setAttr GObject10.outColor 1 1 1 via single commands in my scene and everything's working fine.
If I just type a "cleaned" non- dynamically created version of the script into the script editor, everything is running just fine:
int $moCheck;
$moCheck = `getAttr ($item + ".translateX") `;
int $iter;
if($moCheck != 0)
{
$iter = `getAttr ($item + ".iterations")`;
enlightenIt($item);
$iter += $iter;
setAttr ($item + ".iterations") $iter;
}
if($iter == 10)
{
expression -s "" $item;
}
proc enlightenIt(string $grp)
{
string $mat = (" + $aux + "+ $grp);
vector $col = `getAttr ($mat + ".outColor")`;
vector $col1 = <<$col.x + 0.1, $col.y + 0.1, $col.z + 0.1>>;
setAttr ($mat + ".outColor") ($col1.x) ($col1.y) ($col1.z);
};
I really do not see the cause for this error, so please help if you can!
Error: Illegal attribute in expression: GObject10
message. I have been trying things for hours, now but I can't figure out what's going wrong there- maybe you can help.
Here's the code. The first three strings are for debugging, GObject10 is a group, containing objects and it is connected to a shader named "SShadeGObject10"
string $item = "GObject10";
string $grp = "GObject10";
string $aux = "\"SShade\"";
string $content =
"int $moCheck; \r\n"+
"$moCheck = `getAttr " + $item + ".translateX" + " ` ; \r\n"+
"int $iter; \r\n"+
"if($moCheck != 0)"+
"{ \r\n"+
"$iter = `getAttr " + $item + ".iterations" + " ` ; \r\n"+
"enlightenIt(" + $item +" ); \r\n"+
"$iter += $iter; \r\n" +
"setAttr " + $item + ".iterations " + " $iter;"+
"}\r\n" +
"if($iter == 10)"+
"{ \r\n" +
" expression -s \" \" $item; \r\n" +
"} \r\n" +
"proc enlightenIt(string $grp){ \r\n"+
"string $mat = (" + $aux + "+ $grp); \r\n"+
"vector $col = `getAttr ($mat + \".outColor\")` ; \r\n" +
"vector $col1 = <<$col.x + 0.1, $col.y + 0.1, $col.z + 0.1>>; \r\n" +
"setAttr ($mat + \".outColor\") ($col1.x) ($col1.y) ($col1.z); \r\n"+
"}";
expression -s $content $item;
I can do all the "getAttr GObject10.outColor" or setAttr GObject10.outColor 1 1 1 via single commands in my scene and everything's working fine.
If I just type a "cleaned" non- dynamically created version of the script into the script editor, everything is running just fine:
int $moCheck;
$moCheck = `getAttr ($item + ".translateX") `;
int $iter;
if($moCheck != 0)
{
$iter = `getAttr ($item + ".iterations")`;
enlightenIt($item);
$iter += $iter;
setAttr ($item + ".iterations") $iter;
}
if($iter == 10)
{
expression -s "" $item;
}
proc enlightenIt(string $grp)
{
string $mat = (" + $aux + "+ $grp);
vector $col = `getAttr ($mat + ".outColor")`;
vector $col1 = <<$col.x + 0.1, $col.y + 0.1, $col.z + 0.1>>;
setAttr ($mat + ".outColor") ($col1.x) ($col1.y) ($col1.z);
};
I really do not see the cause for this error, so please help if you can!
