cudarsjanis Posted October 29, 2019 Share Posted October 29, 2019 Hi, Probably easy question, but what would be the way to make this vex code shorter and work for more @id`s, so I don`t have to copy the same line of code multiple times? if(@fid == 0) i@group_fid0 = 1; if(@fid == 1) i@group_fid1 = 1; if(@fid == 2) i@group_fid2 = 1; if(@fid == 3) i@group_fid3 = 1; I basically want to make a group for all primitives with same id. I`m guessing it can be done using arrays, but I`m not too good with them. Thanks Janis Quote Link to comment Share on other sites More sharing options...
Sepu Posted October 29, 2019 Share Posted October 29, 2019 Use the partition Sop. 2 Quote Link to comment Share on other sites More sharing options...
ikoon Posted October 29, 2019 Share Posted October 29, 2019 Hi Janis, I assume that @fid is an integer. You can run this in a prim wrangle: string group_name = "fid" + itoa(i@fid); setprimgroup(0, group_name, @primnum, 1, "set"); 2 Quote Link to comment Share on other sites More sharing options...
cudarsjanis Posted October 29, 2019 Author Share Posted October 29, 2019 26 minutes ago, ikoon said: Hi Janis, I assume that @fid is an integer. You can run this in a prim wrangle: string group_name = "fid" + itoa(i@fid); setprimgroup(0, group_name, @primnum, 1, "set"); Perfect. This is what I was looking for. Thanks 26 minutes ago, Sepu said: Use the partition Sop. Nice one. This works nicely as well with fid`rint(@fid)` Thanks guys! Cheers Janis Quote Link to comment Share on other sites More sharing options...
acey195 Posted November 1, 2019 Share Posted November 1, 2019 Note that @ikoon's method is faster than the partition SOP at least in 17.0x and earlier, have not yet tested in later versions. Difference is of course going to be very small, but can make a difference on heavy geo 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.