PDA

View Full Version : ls -flatten?


EightBit
04-07-2009, 06:38 AM
What is the -flatten flag used for? I don't see what it does:
string $junk[] = `ls -selection`;
// pSphereShape1.vtx[180] pSphereShape1.vtx[265] pSphereShape1.vtx[321] //
string $junk2[] = `ls -sl -flatten`;
// pSphereShape1.vtx[180] pSphereShape1.vtx[265] pSphereShape1.vtx[321] //
print $junk[0];
pSphereShape1.vtx[180]
print $junk[1];
pSphereShape1.vtx[265]
print $junk2[0];
pSphereShape1.vtx[180]
print $junk2[1];
pSphereShape1.vtx[265]
Thanks.

Cheesestraws
04-07-2009, 07:33 AM
The easiest way to demonstrate it would be to select all the vertices on the sphere and then run the command.

jaydru
04-07-2009, 10:15 AM
the flatten flag just looks at each componet individualy

for instance with a cube, select all verts

$verts = `ls -sl`;
// Result: pCube1.vtx[0:7] //


this has created an array with only one entry,
where as

$verts = `ls -sl -fl`;
// Result: pCube1.vtx[0] pCube1.vtx[1] pCube1.vtx[2] pCube1.vtx[3] pCube1.vtx[4] pCube1.vtx[5] pCube1.vtx[6] pCube1.vtx[7] //

this has created an array with one entry per vert,
useful if you want to go through the components in a loop

Leionaaad
04-07-2009, 12:10 PM
true. that's what flatten does. I tried to use it in the past, but I had to give up on trying, because it orders the components by index, not in the order they are selected and I needed in the order I selected.

Robert Bateman
04-07-2009, 12:29 PM
If you require the order of selected vertices, then you are making a selection based tool. In that case, use scriptCtx.

EightBit
04-08-2009, 02:34 PM
Thanks for the replies.
In my original test, I selected verts w/non-continuous numbers, so the results of the ls were the same.
Take care.

CGTalk Moderation
04-08-2009, 02:34 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.