sessionbeer Posted December 8, 2015 Share Posted December 8, 2015 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 1 Quote Link to comment Share on other sites More sharing options...
mestela Posted December 8, 2015 Share Posted December 8, 2015 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 3 Quote Link to comment Share on other sites More sharing options...
sessionbeer Posted December 8, 2015 Author Share Posted December 8, 2015 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? ? Quote Link to comment Share on other sites More sharing options...
mestela Posted December 8, 2015 Share Posted December 8, 2015 Its in the help page for wrangles, admittedly a little blink-and-you'll-miss-it, at the end of the parameters->attributes to match section: http://www.sidefx.com/docs/houdini15.0/nodes/sop/attribwrangle#parameters i only know it because it caused much rejoicing during the beta. Quote Link to comment Share on other sites More sharing options...
mestela Posted December 8, 2015 Share Posted December 8, 2015 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. Quote Link to comment Share on other sites More sharing options...
sessionbeer Posted December 8, 2015 Author Share Posted December 8, 2015 Thanks for the info Matt! It really is a blink and miss it little gold nugget Quote Link to comment Share on other sites More sharing options...
mestela Posted December 8, 2015 Share Posted December 8, 2015 You reminded me, that really should be more explicit in my little vex tutorial, duly updated: http://www.tokeru.com/cgwiki/index.php?title=HoudiniVex Quote Link to comment Share on other sites More sharing options...
tjeeds Posted December 8, 2015 Share Posted December 8, 2015 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. 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.