View Full Version : How to place few fertices world translation values in an array?

 StefanStavrev11 November 2006, 06:49 AMHow to place few fertices world translation values in an array? Here is what i tried but did not work : string \$sel[] = `ls -sl`; for(\$i=0;\$i
Robert Bateman
11 November 2006, 10:23 AM
string \$sel[] = `ls -sl`;
float \$p[]; // < declare it first!
for(\$i=0;\$i<size(\$sel)-1;\$i++) {
for (\$each in \$sel) {
\$p[\$i] = `pointPosition -w`;
}
}

isoparmB
11 November 2006, 11:17 AM
string \$sel[] = `ls -sl`;
string \$each;
float \$currentP[];
float \$p[];

for (\$each in \$sel)
{
\$currentP = `pointPosition -w \$each`;
\$p[`size \$p`] = \$currentP[0];
\$p[`size \$p`] = \$currentP[1];
\$p[`size \$p`] = \$currentP[2];
};

Every three values in the array \$p will be the world coordinate of one point,
this of course is assuming you actually have a point selected.

grantimus
11 November 2006, 07:45 PM
You should probably also use `ls -sl -fl` instead of `ls -sl`. If you have a cube name pCube1 and selec vertices 1,2, and 3 of the that cube are selected, then `ls -sl` will return the string "pCube1.vtx[1:3]". Most commands in Maya won't know what to do with this, pointPosition certainly wont. On the other hand `ls -sl -fl` will return "pCube1.vtx[1],pCube1.vtx[2],pCube1.vtx[3]", this will work much better.

CGTalk Moderation
11 November 2006, 07:45 PM
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.

1