Jump to content
cudarsjanis

[SOLVED] vex groups question

Recommended Posts

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

Share this post


Link to post
Share on other sites

Use the partition Sop.

  • Like 2

Share this post


Link to post
Share on other sites

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");

 

  • Like 2

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

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

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×