Jump to content

Arrays in H15 wrangle nodes


Recommended Posts

Hello,

 

I'm struggling with getting arrays to flow around in the new wrangle nodes and to work in H15.

I found an older file that demonstrated how to import the arrays from other nodes but that was done with the old wrangle nodes, can any one help explain how to do the same but within H15?

 

The import() and getattrib() don't seem to function the same way, or are producing errors for me in H15?

I think a lot of people would appreciate an in-depth example of how to properly create arrays, create attribute arrays, manipulate and import arrays inside various wrangle nodes as it seems a bit of a dark art to be honest! Or for me especially.

 

Thanks

import_arrays_H15.hipnc

  • Like 1
Link to comment
Share on other sites

Some of the questions didn't make sense in the hip file, I think you were making it all more complicated than it needs to be.

 

Get/set a float array attribute:

int nums[] = {1,2,3,4};

i[]@pointnums = nums;
i@foo = i[]@pointnums[8];

To get values from the 2nd input of a wrangle, prefix with @opinput1. You still need to use the variable prefix before that too, so you're other question looks like

i@n = f[]@opinput1_near_array[3];

I noticed that if you don't match the attribute type exactly, it returns 0. Eg, swapping 'f' for 'i' will silently error:

i@n = i[]@opinput1_near_array[3];  // @near_array is a float array, but we're calling it as an int array, bad
Anyway, attached file should explain.
 
 

import_arrays_H15_fix1.hipnc

  • Like 3
Link to comment
Share on other sites

Thanks a lot for your reply Matt!

 

I really didn't think it would be difficult to get the values from the arrays but when it was not working, I kept googling to try and find an answer and just got further and further lost. But thanks for clearing it up.

 

I do have one question though, where do you find out that you had to input the array values like this:

i@n = i[]@opinput1_near_array[3];

compared to what is documented at http://www.sidefx.com/docs/houdini15.0/vex/arrays

int nums[] = { 0, 1, 2, 3, 4, 5 };
int n = nums[10]; // Returns 0
int b = nums[-2]; // Returns 4

I know the example above occurs within a single node, but the documentation doesn't say anything about the way you correctly imported the array value in another node?  :huh: ?

Link to comment
Share on other sites

Oh, the general purpose idea of '@' syntax is a feature of vex wrangles. If you're reading and writing geometry attributes, you can use the @attrname shortcut rather than using point() or getattribute() calls.

If you were doing pure vex (say for a shader or a HDA), you need to go the long way.

Link to comment
Share on other sites

Another strategy for anyone who's curious, VOPs supports arrays quite nicely now. All the array functions are subtabbed in the node menu, you can build up what you want and then right click on the Vopnet to view the VEX code that it generates.

  • Like 1
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...