simple for loop grouping question
1691
1
0
-heavy-
Member
62 posts
Joined: Oct. 2007
Offline
June 22, 2018 4:52 p.m.
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
BabaJ
Member
2127 posts
Joined: Sept. 2015
Offline
June 22, 2018 9:05 p.m.
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