Hi everybody,
I'm trying to write a script that will take a selection of two verteces (on pPlane1 for now) and realign the plane's pivot to rotate on the edge between the two selected points. When I run my current script, the location of the pivot works, but the angle is always slightly off. Any ideas on this one?
Thanks!
{
string $sel[] = ls -sl -fl -l
;
float $pointA[] = pointPosition -w $sel[0]
;
float $pointB[] = pointPosition -w $sel[1]
;
spaceLocator -p $pointA[0] $pointA[1] $pointA[2] -n locatorA;
xform -cp;
spaceLocator -p 0 0 0 -n locatorB;
xform -cp;
move -a $pointB[0] $pointB[1] $pointB[2] locatorB;
aimConstraint -offset 0 0 0 -weight 1 -aimVector 1 0 0 -upVector 0 1 0 -worldUpType "vector" -worldUpVector 0 1 0 locatorA locatorB;
delete locatorB_aimConstraint1;
float $x = getAttr locatorB.rotateX
;
float $y = getAttr locatorB.rotateY
;
float $z = getAttr locatorB.rotateZ
;
print ( $x + " " + $y + " " + $z);
xform -ra $x $y $z pPlane1;
move -a $pointB[0] $pointB[1] $pointB[2] pPlane1.scalePivot pPlane1.rotatePivot ;
};