Python: Getting items loaded via loadItemsFromFile()

   933   2   1
User Avatar
Member
240 posts
Joined: Oct. 2014
Offline
Python question...

I'm using hou.Node.loadItemsFromFile() and although it works fine, it does not seem return any objects. The items are selected after the load, but I think other items which were selected prior to the load remain selected as well.

What is the best way to get a handle on the nodes loaded by loadItemsFromFile()?

And... any chance there is an RFE already in place for augmenting this method to provide a return?
Edited by Tim Crowson - Jan. 5, 2023 13:22:07
- Tim Crowson
Technical/CG Supervisor
User Avatar
Member
1914 posts
Joined: Nov. 2006
Offline
A proper return value from loadItemsFromFile() would be ideal (not sure if there's an RFE for that or not) but as you mention you can get at the things you want by using the fact that Houdini will add the loaded items to the list of selected items as long as you just clear them first:
hou.clearAllSelected()
my_node.loadItemsFromFile("/some/path.cpio")
loaded_items = hou.selectedItems()
Edited by graham - Jan. 5, 2023 14:15:19
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
240 posts
Joined: Oct. 2014
Offline
Thanks, Graham! Hope all is well in your corner of the world!
- Tim Crowson
Technical/CG Supervisor
  • Quick Links