Script for creating joints based on existing locators?
Hey there!
I'm currently in a scripting class, and I've decided to write a script to create joints based on a selection of locators. Said joints would need to be automatically translated to the position of the locators - and this is the part I'm struggling with. Here's what I have up to now:
string $selectedLocators[] = `ls -sl`;
int $selectionSize = size($selectedLocators);
int $i;
//rename locators temp
for ($locatorName in $selectedLocators)
{
rename $locatorName tempName_loc;
};
//create appropriate number of joints
if ($selectionSize >=1)
{
for ($i = 1; $i <= $selectionSize; ++$i)
{select -cl;
joint;
}
}
else
{error ("Please select locators");}
//rename joints temp
select "joint*";
string $createdJoints[] = `ls -sl`;
for ($jointName in $createdJoints)
{
rename $jointName tempName_joint;
}
My plan was to find a way to match the name of the tempJoints to the corresponding tempLocs, but I'm not sure how to approach that. I know there are faster ways to get around it, but I'm trying to do it with the limited knowledge of mel I have - so if it's possible to get the next step done the way I originally intended to, that'd be awesome.
Thanks in advance,
Gio