Hello,
I'm working on a UI which makes changes to particles in the expression editor through the dynEpression function. I've made it to import an instance of the particle rig each time you click a button. Instead of using a new namespace for each instance, to resolve the duplicate name issue, I used the rename function to rename all of the contents with a counter. This works fine, but it calls for the need to then refer to which name to plug into the dynExpression method since it will be telling the expression editor which particleShape it will be working on. (The dynExpression method just writes a string to the expression editor)
So to do this I used the ls function for the selected particlesShape which works fine. Then for all of the other contents I was trying to use the tokenize function to split up the particlesShape name so I could get which counter object is currently selected. Then I would just concatenate the string in the dynExpression line to add that number to the end of the object name. The problem I'm having is the tokenize line:
string $inSelTokenBuffer[];
tokenize($inCurrentSel[0],"P", $inSelTokenBuffer);
The name of the object being passed to this is lightningHermiteP#, where the # will be the number of the counter. I've even tried using the stringArrayToString function on the $inCurrentSel[0] but I know that's not necessary. The error I'm getting is:
// Error: Invalid call to "tokenize". Check number and types of arguments expected by the procedure. //
I'm pretty sure the syntax and types are okay so I'm stuck here. I've solved the issue by using namespaces, but don't like to have multiple objects with the same name if avoidable. Here is the procedure. WARNING: the dynExpression line is going to look very disgusting so be careful if you have a light stomach. That all works though so don't worry about it unless you have a suggestion of how to make it better/more efficient. The other procedures work fine and shouldn't affect this so I won't post them.
proc setRunExp(){
float $inFreq = `floatSliderGrp -q -value "freqSldr"`;
float $inAmp = `floatSliderGrp -q -value "ampSldr"`;
float $inMidRad = `floatSliderGrp -q -value "midRadiusSldr"`;
float $inEndRad = `floatSliderGrp -q -value "endRadiusSldr"`;
float $inFrontTap = `floatSliderGrp -q -value "frontTapSldr"`;
float $inEndTap = `floatSliderGrp -q -value "rearTapSldr"`;
float $inMidPoint1 = `floatSliderGrp -q -value "frontMidPntSldr"`;
float $inMidPoint2 = `floatSliderGrp -q -value "rearMidPntSldr"`;
$inCurrentSel = `ls -sl`;
$pasteSel = $inCurrentSel[0];
string $inSelTokenBuffer[];
tokenize($inCurrentSel[0],"P", $inSelTokenBuffer);
$pasteToken = $inSelTokenBuffer[1];
dynExpression -s (""+$pasteSel+".opacityPP = rand(.7, .97);\r\n\r\n\r\n\r\n//-----------------------------------------\r\n// hermite function\r\n//-----------------------------------------\r\n\r\nvector $lgs = <<startLoc"+$pasteToken+".translateX, startLoc"+$pasteToken+".translateY, startLoc"+$pasteToken+".translateZ>>;\r\n\r\nvector $lgsT = <<startTan"+$pasteToken+".translateX, startTan"+$pasteToken+".translateY, startTan"+$pasteToken+".translateZ>>;\r\n\r\nvector $lge = <<endLoc"+$pasteToken+".translateX, endLoc"+$pasteToken+".translateY, endLoc"+$pasteToken+".translateZ>>;\r\n\r\nvector $lgeT = <<endTan"+$pasteToken+".translateX, endTan"+$pasteToken+".translateY, endTan"+$pasteToken+".translateZ>>;\r\n\r\nvector $hermite = hermite ($lgs, $lge, $lgsT, $lgeT, "+$pasteSel+".age/"+$pasteSel+".lifespanPP);\r\n\r\nfloat $noiseY = (" + $inAmp + " *((rand((rand(1,2)),(rand(3,5)))))*noise((time)+("+$pasteSel+".particleId * " + $inFreq + "))) * "+$pasteSel+".noiseMult;\r\nfloat $noiseX = (1*noise((time+10)+("+$pasteSel+".particleId * .1))) * "+$pasteSel+".noiseMult;\r\n\r\n"+$pasteSel+".position = $hermite + <<0, $noiseY, $noiseX>>;\r\n\r\n\r\n//----------------------------------------\r\n//-----condition to tapper from Front\r\n\r\nif("+$pasteSel+".radiusPP < " + $inMidRad +"){\r\n\r\n\tif("+$pasteSel+".age < ("+$pasteSel+".lifespanPP*" + $inMidPoint1 + "))\r\n\t\t"+$pasteSel+".radiusPP+=" + $inFrontTap + ";\r\n}//end if's\r\n\r\n\r\n//----------------------------------------\r\n//-----condition to tapper from Back\r\n\r\nif("+$pasteSel+".radiusPP > " + $inEndRad + "){\r\n\r\n\tif("+$pasteSel+".age > ("+$pasteSel+".lifespanPP*" + $inMidPoint2 + "))\r\n\t\t"+$pasteSel+".radiusPP-= " + $inEndTap + ";\r\n}//end if's") -rbd $pasteSel;
}//end setRunExp
Thanks in advance for your time and any help or suggestions you can offer.
DaveJ