Hi,
I have been trying to create a particle attribute using MEL and make it appears in the attribute editor and also adding some expression to it but unfortunatelly can't succeed. Here is the code:
//put the selected particle into a string variable $myParticle
string $selectionList[0]=ls -sl
;
string $myParticle=$selectionList[0];
//add and set the TornadoRadius
addAttr -ln "tornadoRadius" -dt "doubleArray" $myParticle;
setAttr -e -keyable true ($myParticle+".tornadoRadius");
//add a creation expression to the new created attribute which is tornadoRadius
string $exprCreate=dynExpression -c -q -s $myParticle
;
$exprCreate+="tornadoRadius=rand(.75,1.5)";
dynExpression -c -s $exprCreate $myParticle;
//add a Runtime Before Dynamic expression
//to the per particle "position" attribute
string $exprRBD= dynExpression -rbd -q -s $myParticle
;
$exprRBD += "position= <> ";
dynExpression -rbd -s $exprRBD $myParticle;
print "All Is Well!!!";
And here is the error i get:
// Error: Attribute not found or variable missing '$': tornadoRadius
Which means in my opinion that i didn't successfuly create the tornadoRadius attribute.
But on the other side. if i only run this part of the code with the particle selected:
//put the selected particle into a string variable $myParticle
string $selectionList[0]=ls -sl
;
string $myParticle=$selectionList[0];
//add a Runtime Before Dynamic expression
//to the per particle "position" attribute
string $exprRBD= dynExpression -rbd -q -s $myParticle
;
$exprRBD += "position= <> ";
dynExpression -rbd -s $exprRBD $myParticle;
everything goes well and the expression is written within the "position" attribute box in the attribute editor. I will really appreciate if someone can help me to solve this "create particle attribute via MEl" problem. Thanks in advance.