Jump to content
90okm

Setting array attribute element via attribute wrangle

Recommended Posts

Hi ! trying to work with vex snippets and faced the problem !

I've created an integer array attribute on primitives and want to fill it with some values in attrib wrangle

but i always get the error message of "Ambiguous call to array index operator ''. Candidates are: 'float vector4[int]', 'float vector2[int]', 'float vector[int]'" 

 

being declared within wrangle node the construction like this

i[]@arr = {};
@arr[0]=@primnum-21;

works fine

 

aarr_created.png

error.png

wrangle_error.hip

Edited by 90okm

Share this post


Link to post
Share on other sites

Try this in wrangle Primitive node:

i[]@arr = {-1,0,1}; // Create an array with values
i@arr[1] = @primnum; // Set primnum in array[1]

This create and set value of an integer array.

Edited by fsimerey

Share this post


Link to post
Share on other sites
14 hours ago, sasho78 said:

i[]@arr[0] = 21;

this seems to work

Yes it works, but it looks like declaring new attribute....that's why i was confused.

thanks

Share this post


Link to post
Share on other sites

Might be wrong, but if the attribute exists then it's just a statement what type of attribute you are trying to access, otherwise it has to guess what type of attribute is and it seems that it's not very good at it :)

It's not a bad practice to state the type of the attribute every time you want to work with it.

Share this post


Link to post
Share on other sites

Here the list of known attributes which does not require type specified. As stated, all others will be assumed as floats. But you need to write type only once, later you may omit type:

v@test = {1, 1, 1};  // Type need to be specified once.
@test = 0;           // Still a vector assigment, will be set as {0, 0, 0}.

You also can declare attributes by writing full type name, in that case value will be used as default:

vector @test = {1, 2, 3};

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

×