Jump to content

Read more than 4 components per attribute?


Soar

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
Link to comment
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
Link to comment
Share on other sites

  • 2 weeks later...
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.

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...