I am working on a Script for automating the rigging process and have become stuck on how to measure a distance in 3d using MEL.
I have a locator at the origin, (baseLocator) and one that the user must place at the top of the character’s head (heightLocator). Doing this by hand I would use the measure tool, and the MEL for that is ‘distanceDimension’. The flags for distanceDimension are -startPoint and -endPoint, which each expect 3 linear numeric values.
The Code so far:
string $baseNode[] = listRelatives -shapes "baseLocator";
string $heightNode[] = listRelatives -shapes "heightLocator";
float $baseVec[] = spaceLocator -query -position $baseNode[0];
float $heightVec[] = spaceLocator -query -position $heightNode[0];
string $dist = distanceDimension -startPoint ($baseVec[0]) ($baseVec[1]) ($baseVec[2]) -endPoint ($heightVec[0]) ($heightVec[1]) ($heightVec[2]);
string $dShapes[] = listRelatives -parent $dist;
rename $dShapes[0] myDistance;
float $charHeight = getAttr myDistanceShape1.distance;
float $scaleFactor = ($charHeight / 179.485);
I start getting errors on the 3rd Line, "Cannot convert data of type string to type float[]. // "
How can I get the spatial coordinates of the locators into the distanceDimension command?
I want to do another script that measures a distance in 3d space and then evenly divides it placing joints evenly for the spine. I need to figure this out first though…
I truly appreciate any MEL experts out there being able to explain this to me.
Thank you!