Dynamic Attribute 'declaration' in vex

   3568   5   1
User Avatar
Member
2042 posts
Joined: Sept. 2015
Offline
Hello,

Does anyone know if it's possible to create attributes ‘dynamicaly’ in vex?

Just for simplicities sake, say in a point wrangle create dynamic number of attributes that are each an array of values.

Where the user sets the number of arrays created with either 1,2,3 or 4 and so on etc. with a parameter slider.

It's not important what the dynamicly created arrays are named ie., I don't need this to be ‘displayed’ or available for the user end.

Just so I can access them distinctly according to how many were created.

According to documents vex currently does not support multi-dimensional arrays, which if they did I could easily implement what I want by using an array of arrays.

I'm putting this question out there before I make an RFE, in case there is a way to do the equivalent of a multi-dimensional array.

Thanks for any help.
User Avatar
Member
806 posts
Joined: Oct. 2016
Offline
Maybe this video is of some help?



Marc
---
Out of here. Being called a dick after having supported Houdini users for years is over my paygrade.
I will work for money, but NOT for "you have to provide people with free products" Indie-artists.
Good bye.
https://www.marc-albrecht.de [www.marc-albrecht.de]
User Avatar
Member
2042 posts
Joined: Sept. 2015
Offline
Thanks malbrecht…I'll have a look at it.
User Avatar
Member
2042 posts
Joined: Sept. 2015
Offline
Hmmm…I think I should have made my original post shorter to just asking if there is a ‘workaround’ to accomplish arrays of arrays in vex.

This video doesn't do that…but I do see why you suggested it, as it does relate to how I ‘framed’ my original post.

Thanks for your input malbrecht.
User Avatar
Member
8591 posts
Joined: July 2007
Offline
very convoluted question, I guess it depends on the final use
you can always create points with array attribute
create as many points you want addpoint() => first dimension
each can have different array as an attrib setpointattrib() => second dimension
and of course you can as well create many attribs instead of points setpointattrib() (or addpointattrib() prior to H16), depending on needs
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Staff
6220 posts
Joined: July 2005
Offline
If you want ragged array-of-arrays, and you just need to store them in attributes and retrieve them, you can use a pair of array attributes. One stores the lengths of your sub-arrays, the other raw data.

float @arraydata[];
int @arraylen[];
int curstart = 0;
foreach (int len; arraylen)
{
   float a[] = @arraydata[curstart:curstart+len];
   // Work on a[]
   curstart += len;
}

We do something similar to export normal arrays to OpenCL as they are effectively array-of-arrays from the viewpoint of an OpenCL kernel.

Rather than length, you can also store the absolute start allowing random access. Length can then be specified separately, or implied as a difference between starts.

This is all basically re-inventing memory management using a normal float array as just an arbitrary memory container. So all squarely falls under “workarounds”; which is why there already are RFEs for proper arrays-of-arrays in VEX.
  • Quick Links