VEX Arrays

   1548   3   0
User Avatar
Member
209 posts
Joined: Jan. 2013
Offline
Hello!

1) How can I create an array of arrays in VEX?

Example,

Iterate over primitives:
int an_array[];
int pts[] = primpoints(0, @primnum);

for(int i = 0; i < @numprim; ++i){
    push.(an_array, pts);
}
setdetailattrib(0, "an_array", an_array);

It should be like that in my understanding,
[[1,2,3], [4,6], [7,8,10,15]]
, but I get a single array with values.
[1,2,3,4,6,7,8,10,15]


2) How can I overload the Push function so that it can work with custom structures?

Example,

struct Test{
   int index;
   vector data;
};

Test test;
test.index = 1;
test.data = {1,0,0};

vector an_array[];
push(an_array, test);

But this code causes an error.
Edited by alexwheezy - March 10, 2020 10:26:02
User Avatar
Member
142 posts
Joined: Aug. 2009
Offline
Maybe it helps I use H 16.5, so what you want to achieve???

Post please your File

Attachments:
Structcolo.hipnc (75.6 KB)

User Avatar
Member
8594 posts
Joined: July 2007
Offline
1) Houdini doesn't support multidimensional arrays
https://www.sidefx.com/docs/houdini/vex/arrays.html [www.sidefx.com]

2) if this is a wrangle you need to define structs in outer code (./attribvop1/snippet1/Outer Code parameter)
and then this part:
vector an_array[];
push(an_array, test);

should be changed to this
Test an_array[];
push(an_array, test);

as you can only put float to float array, vector to vector array, Test to Test array, but not Test to vector array, etc…
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
209 posts
Joined: Jan. 2013
Offline
Thank you tamte for the quick reply and clarification. It is a pity, then will have to solve their problems in a different way.
  • Quick Links