How to persist an Attribute in Geometry Detail

   1900   1   0
User Avatar
Member
8 posts
Joined: Dec. 2013
Offline
I have a text file representing a regression tree for some machine learning evaluation I'm doing on the GPU.

I'm using a python node to load the text file data, then calling the following to add a detail to the geometry.
left_attrib = geo.addAttrib(hou.attribType.Global, "left", leftArray)

The problem is that I have to load the text file and call addAttrib every frame for it to persist, costing very precious milliseconds. Am I approaching this wrong? I just need some way to take my data and present it to next node (This OpenCL node: https://www.sidefx.com/forum/topic/44718/). [sidefx.com]

Ideally I'd like to only load the txt file once, maybe if frame is 1 or with some reload button.

I'd really appreciate some help with this, thanks.
User Avatar
Member
2531 posts
Joined: June 2008
Offline
I think with attributes you may need to check if they exists before you add them.
node = hou.pwd()
geo = node.geometry()

# Add code to modify contents of geo.
# Use drop down menu to select examples.

curAttrib = geo.findGlobalAttrib("my_detail")
if curAttrib == None:
# Time to create attribute.
s = 1.0
curAttrib = geo.addAttrib(hou.attribType.Global, "my_detail", s)
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
  • Quick Links