setting point array attributes with python

   5733   2   0
User Avatar
Member
3 posts
Joined: June 2017
Offline
is it possible to set point vector/float/int array attributes with python in geometry module? Im using houdini 17.0.502 version. there are floatList methods for global attributes in geometry module but no such things for points
User Avatar
Member
2 posts
Joined: Oct. 2018
Offline
yes.
node = hou.pwd()
geo = node.geometry()

newValue = 1
for point in geo.points():
    point.setAttributeValue('attributeName',newValue)

you can access the points and use the setAttributeValue method to give them a new attribute. The code above iterates through all points in the geometry and sets their value to 1.

if you need to access individual faces/prims you have to get at the points a little differently by getting the vertex first something like
prims = geo.prims()
for prim in prims:
    verts = prim.vertices()
    for vert in verts:
        point = vert.point()
        point.setAttributeValue('attributeName',newValue)
User Avatar
Member
3 posts
Joined: June 2017
Offline
I know the iteration ways and I dont want to use them as they are slow when dealing with heavy meshes. thats why the geometry module. I can set all other attribute types in geometry module except point/prim arrays. is this just left out from python implementation?
Edited by kojala_home - Dec. 29, 2019 06:22:30
  • Quick Links