python sop array attributes

   2203   1   1
User Avatar
Member
17 posts
Joined: Feb. 2018
Offline
having trouble writing a list of floats to a detail attribute via the python sop. instead of a float array of size n it seems to create a float of size n.
what python type should I use for hou to cast it to a float array instead?
Edited by nvki - Dec. 11, 2020 19:27:53

Attachments:
cl_array.hiplc (84.3 KB)

User Avatar
Member
17 posts
Joined: Feb. 2018
Offline
idk how i missed that there was a separate method of hou.Geometry, addArrayAttribute for that. so to construct a float array with python:
node = hou.pwd()
geo = node.geometry()
pts = geo.points()

data = [float(p.number())/float(len(pts)) for p in pts]

detail = geo.addArrayAttrib(hou.attribType.Global, "test", hou.attribData.Float, 1)
geo.setGlobalAttribValue("test", data)
Edited by nvki - Dec. 11, 2020 21:00:12
  • Quick Links