PDA

View Full Version : Index of selected polygons



Kevin Kipper
02-14-2008, 07:02 PM
Is there a way of identifying the individual polygons in a user's selection so that command sequences can be run on the individual polygons? Perhaps an array somewhere that has the selected index numbers saved?

For example, I have a mesh containing 100 polygons, 10 of which are randomly selected by the user. The polycount() show 10 polys selected but I want to be able to isolate each of the 10 selected polys and modify them individually, like extrude each polygon on the Y axis a different amount.

Thanks!

Kevin

art
02-14-2008, 07:29 PM
One way of doing it would be to copy the polygon IDs from the system provided polygons array then then use selpolygon with each ID to select one polygon at the time.
This is a rough sketch from head, might have syntax errors:

selmode(USER);
editbegin();
foreach(poly,polygons)
{
mypolys = mypolys + poly;
}

for(n = 0 ; n < mypolys.count() ; n++)
{
selpolygon(SET, POLYID, mypolys[n]);
//do something with selection
}
editend;

Dodgy
02-14-2008, 08:00 PM
You don't need the foreach, just

editbegin();
mypolys=polygons;
editend();

will do it. You can't call selpolygon() in an editbegin/end section either I don't think, as it's a command sequence, not meshedit command.

art
02-15-2008, 07:30 AM
You don't need the foreach, just

editbegin();
mypolys=polygons;
editend();

will do it. You can't call selpolygon() in an editbegin/end section either I don't think, as it's a command sequence, not meshedit command.


You learn something new everyday + I didn't remember :eek: if selpolygon runs in edit mode or not without actually trying it so I mentioned that it might contain errors. Thanks for clarification :)

Kevin Kipper
02-15-2008, 12:54 PM
Thanks for the help. That solved it.