simple for loop grouping question

   1691   1   0
User Avatar
Member
62 posts
Joined: Oct. 2007
Offline
i got stuck on my for loop cause i am not sure how to use the modulo..

i have 12 connected primitives with a class attribute and i want to have 6 groups with it
but only with the first and second and the third and fourth and so on.

so i did the following
int count = int(1+(@class/2) );
for(int i = 0; i < count; i++)
{
    string groupname = sprintf("layer%i",i);
    setprimgroup(0,groupname, @primnum, 1, "set");
    setprimgroup(0,groupname, @primnum+count, 1, "add");
}
but that does not work,

do i need a second for loop in the first or modulo with 2 to get 01 23 45 67 89 etc..
?

cheerz the Heavy
Janko Kissel
Maya & Houdini Smoke and Demolition VFX-Artist
http://vimeo.com/heavyatvimeo [vimeo.com]
https://www.youtube.com/user/masterheavyone/videos [youtube.com]
User Avatar
Member
2127 posts
Joined: Sept. 2015
Offline
run over primitives with..

string BaseName, GroupName;  

BaseName = "layer_";

GroupName = BaseName + itoa( (@primnum/2 + 1));
setprimgroup(geoself(), GroupName, @primnum, 1, "set");
Edited by BabaJ - June 22, 2018 21:08:08
  • Quick Links