Jump to content

Arrays in vex and python with attributes question


Tyfx567

Recommended Posts

Hey guys, 
 

I am wanting to loop over points and take say some random attribute from 0-10 let's say on the points. 
I want to take that attribute and for every point store the previous attribute of the previous point it is looping through and append it to the list.

example:

             num      numarray

point 0 = 2          [2]

point 1 = 4         [2,4]

I attempted to do this in vex and it already is looping over the points so you can't do an append as far as I am aware because you can't look at previous point. If you can please let me know


With python you can, but since I am so new to python I can't even get arrays working in python
I create attribute with "attribute create" node before python node so I get [] empty array on the point attribute. I call it "emptyarray". 
then I try this
 

node = hou.pwd()
geo = node.geometry()

points = hou.Geometry.points(geo)
testarray = [2,5]

#test
#readA = hou.Geometry.findPointAttrib(geo, "emptyarray")

for i in points:
    
    hou.Point.setAttribValue(i, 'emptyarray', testarray)
    

But it does nothing but error out

 

Link to comment
Share on other sites

That was exactly what I am after thank you! If I have any other issues I will post them here thank you so much!
Is int @array[]; how you make a blank array attribute? Because that is extremely useful. I didn't know you could do that with arrays. I thought you had to add it with addpointattrib and then setpointattrib..

Link to comment
Share on other sites

yes, that's how you define empty variables or attributes.

you just have to change your point of view. look at the wrangle from every point angle. it evaluates at every point, so for example if I'm on point number 10, what should I write to do this or that.

coming from maya, It took me awhile to understand houdini ways,... :)

 

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