I’m making a little automated script to link the displacement alpha gain for displacement maps to object scale and I’ve hit a snag since I’m new to MEL and coding in general. I want the expression part in this script to use the float variables, not the set values but when I try and put them in brackets and quotes, it chokes. I’m sure it’s just me not understanding what they do (what do the quotes do?). Anyway, if someone can tell me how to get the expression parts to use the variables, it would help a lot:
string $mySelection[] = `ls -sl`;
float $gainval = `getAttr (($mySelection[0])+".alphaGain")`;
float $gainoffset = `getAttr (($mySelection[0])+".alphaOffset")`;
setAttr (($mySelection[0])+".alphaGain") $gainval;
setAttr (($mySelection[0])+".alphaOffset") $gainoffset;
setAttr (($mySelection[0])+".filterType") 0;
expression -string "ZBrushDispMap.alphaGain = 0.149 * pSphere11.scaleX";
expression -string "ZBrushDispMap.alphaOffset = ZBrushDispMap.alphaGain * -0.5";
edit: I just realized that I’ll need to get the sphere object as a variable too. Is there a way to getAttr on the object’s transform node from the Displacement map selection (which is what’s needed for the script).