PDA

View Full Version : messing w/ verts


Doogie
12-22-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

misterdi
12-22-2003, 04:37 AM
Use flatten in your `ls` commannd.

`ls -sl -fl` will list all your selections in flattened mode, no grouping.

Doogie
12-22-2003, 06:17 AM
ROCK! Excellent, that's what I was looking for. Any reason to use this "compressed" form?


Thanks

misterdi
12-22-2003, 06:44 AM
One obviuos reasons, memory efficiency.

Imagine if you have undo stack filled with all the 100,000 vertex list would be a waste.

Levitateme
12-29-2003, 10:31 AM
So paul, did you finish that script then?

CGTalk Moderation
01-17-2006, 12:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.