Jump to content

Store a Collection in a Node?


Recommended Posts

Hi All,


Is there any way to store a collection in a node? I checked the parameter list and there does not seem to be a list or collection property available.


IS there any other way to attach a list to a node?



Edited by Atom
Link to comment
Share on other sites

You can turn a parameter into a menu and store values that way.


Or, I don't know if you want to use python for this but if you can you can pickle a list, store it as user data on the node and then unpickle and retreive it later.

import json
node = hou.node('/path/to/node')

my_list = range(1,10)

# store the list on the node
node.setUserData('my_list', json.dumps(my_list))

# get the list back
list_copy = json.loads(node.userData('my_list'))

print list
  • Like 1
Link to comment
Share on other sites

In the past I've used pickle for this. Looks like json does a similar thing?




It can be done at the node instance level like the example jonp posted and it can also be done at the OTL level so the data is persistent.



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.

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