Jump to content
Sign in to follow this  
gerardocastellanos

if in list (vex)

Recommended Posts

You can use find() function, if the resulting index is negative, element is not in the array

Share this post


Link to post
Share on other sites

I stored different index (integer number) in my primitives, and I want to create an array detail attribute with all my different index.

sometimes my geometry could has 4 different index, for example (3,6,7,2), but in another case it could has 6 or 8 different numbers.

my idea is store in a detail attribute that list of numbers (index)

 

I create an primitive wrangle with this:


 

int indexList[] = detailattrib(0, "indexList",0,1);

if (!find(indexList, @index)){
push(indexList, (int)@index);

setdetailattrib(0, "indexList", indexList);
}

 

but it does not work as I expect.

what I am doing wrong?

 

thanks

Edited by gerardocastellanos

Share this post


Link to post
Share on other sites

as I mentioned if returned index by find() is negative it's not found

your test simply tests if it's 0, which is actually still a valid index

 

so you want to do :

if (find(indexList, @index) < 0)
Edited by anim

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
Sign in to follow this  

×