Jump to content
Soar

Read more than 4 components per attribute?

Recommended Posts

Hey there!
I'm trying to assign a 'MatID' prim attribute value based on incoming data. I'm currently importing data from a JSON file which has an array called 'primMatID'. There are 10 entries in this array and they are being read into Houdini as separate attributes; primMatID[0], primMatID[1]..... primMatID[9]. Using an attribute wrangle, I'm assigning the value of each of those 'primMatID' entries to the 'MatID' attribute on a specific prim/face of a simple model (eg pentagon). I've only been able to achieve the first four, inappropriately treating the 'primMatID' entries as vectors  *blushes* in a vex wrangle, but obviously vector4 is the biggest there is, so the fifth through tenth entries of the JSON array cannot be captured with this approach.

For the attached image, is it possible to transfer the primMatID[4] value of 8 to prim 6? Any help would be greatly appreciated!

Thanks in advance.

question.jpg

Edited by Soar
More accurate title

Share this post


Link to post
Share on other sites

You should be able to check the attribute data type via node info. Then you could use this type to access the contents. How did you import the json data?

  • Thanks 1

Share this post


Link to post
Share on other sites
int array[] = {1,2,3,4,5,6};

// create primMatID_0, 1, 2,...
for(int i=0;i<len(array);i++){
    int  a = addattrib(0, "point", "primMatID_"+itoa(i), array[i]);
}

// create an INT array attrib
i[]@primMatID=array;

you could do something like that in a wrangle (2 different options)

Edited by bunker
  • Thanks 1

Share this post


Link to post
Share on other sites
On 17/11/2022 at 1:56 AM, haggi said:

You should be able to check the attribute data type via node info. Then you could use this type to access the contents. How did you import the json data?

Hi haggi,
I imported the JSON file using Python, and the attribute here as a list. When the data is inspected in Houdini as you suggested, the data type is an '10int'. I can read up to the first 4 of these ints, but not the last 6. I've since found that it looks like I may have to change how I'm importing the data as according to the following two posts, what I'm trying to do can't be done with VEX. Sorry for my delay getting back to you. Thank you for your help.

https://www.sidefx.com/forum/topic/44766/?page=1#post-235606
 

On 17/11/2022 at 11:38 AM, bunker said:

int array[] = {1,2,3,4,5,6};

// create primMatID_0, 1, 2,...
for(int i=0;i<len(array);i++){
    int  a = addattrib(0, "point", "primMatID_"+itoa(i), array[i]);
}

// create an INT array attrib
i[]@primMatID=array;

you could do something like that in a wrangle (2 different options)

Hi bunker,
Thank you for your suggestions. When I tried the first suggestion here, I create individual attribute types named nicely with ints, however they are loaded with the values I input (such as 1,2,3,4,5,6 as shown this example). I was hoping to split an incoming '10int' data type with VEX into individual attributes and associated values. Since posting my question, it appears at the above linke that what I am trying to do is not possible with VEX, so I will look to reformat the data. Sorry for my delay getting back to you. Thank you for your help.

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

×