Doogie
12 December 2003, 04:24 AM
Someone asked me to write a script to snap selected verts to an axis. I thought, "sure, give me a couple mins"
I find this really annoying how Maya will list verts (example: pSphere1.vtx[298] Sphere1.vtx[318:319]). I know what it's doing (listing sequencial verts w/ colons in between), but this is annoying when trying to automate stuff. Any suggestions?
global proc pfSetVal ()
{
$win = "pfSetValWin";
if (`window -exists $win`)
deleteUI $win;
pfSetValWin $win;
showWindow $win;
}
proc pfSetValWin (string $win)
{
// create the window
window -t "pf Set Value" $win;
columnLayout -cat both 5 -adj true -rowSpacing 1;
radioButtonGrp
-numberOfRadioButtons 3
-label "Axis:"
-labelArray3 "X" "Y" "Z"
-on1 ""
-on2 ""
-on3 ""
-sl 1
axisRadButGrp;
attrFieldSliderGrp -min -10.0 -max 10.0 -l "Value:" pfGhostingSpread;
button -l "Ok" -c "pfSetTheVal()";
}
proc pfSetTheVal()
{
string $sel[] = `ls- sl`;
string $vert;
string $axis = "x";
float $transVal[];
if (size($sel) == 0)
{
error "select something";
}
for ($vert in $sel)
{
$transVal = `xform -q -t $vert`;
switch ($axis){
case "x":
xform -t 0 $transVal[1] $transVal[2] $vert;
print ("xform -t 0 "+$transVal[1]+" "+$transVal[2]+" "+$vert+"\n");
break;
case "y":
xform -t $transVal[0] 0 $transVal[2] $vert;
break;
case "z":
xform -t $transVal[0] $transVal[1] 0 $vert;
break;
default:
error "No axis selected";
break;
}
}
}
pfSetVal();
In previous scripts I've stripped everything out then rebuild the "Obj.vtx[]" afterword... but that seems wastefull and annoying to rewrite everytime. (ehh, i guess ill write a script to strip it all out for me if i have to).
any help would be appreciated. thx
-Paul
I find this really annoying how Maya will list verts (example: pSphere1.vtx[298] Sphere1.vtx[318:319]). I know what it's doing (listing sequencial verts w/ colons in between), but this is annoying when trying to automate stuff. Any suggestions?
global proc pfSetVal ()
{
$win = "pfSetValWin";
if (`window -exists $win`)
deleteUI $win;
pfSetValWin $win;
showWindow $win;
}
proc pfSetValWin (string $win)
{
// create the window
window -t "pf Set Value" $win;
columnLayout -cat both 5 -adj true -rowSpacing 1;
radioButtonGrp
-numberOfRadioButtons 3
-label "Axis:"
-labelArray3 "X" "Y" "Z"
-on1 ""
-on2 ""
-on3 ""
-sl 1
axisRadButGrp;
attrFieldSliderGrp -min -10.0 -max 10.0 -l "Value:" pfGhostingSpread;
button -l "Ok" -c "pfSetTheVal()";
}
proc pfSetTheVal()
{
string $sel[] = `ls- sl`;
string $vert;
string $axis = "x";
float $transVal[];
if (size($sel) == 0)
{
error "select something";
}
for ($vert in $sel)
{
$transVal = `xform -q -t $vert`;
switch ($axis){
case "x":
xform -t 0 $transVal[1] $transVal[2] $vert;
print ("xform -t 0 "+$transVal[1]+" "+$transVal[2]+" "+$vert+"\n");
break;
case "y":
xform -t $transVal[0] 0 $transVal[2] $vert;
break;
case "z":
xform -t $transVal[0] $transVal[1] 0 $vert;
break;
default:
error "No axis selected";
break;
}
}
}
pfSetVal();
In previous scripts I've stripped everything out then rebuild the "Obj.vtx[]" afterword... but that seems wastefull and annoying to rewrite everytime. (ehh, i guess ill write a script to strip it all out for me if i have to).
any help would be appreciated. thx
-Paul