As per the tutorial
import os
buildings_path = hou.node(“.”).parm(“path_to_buildings”).eval()
buildings_folder = os.listdir(buildings_path)
print buildings_folder
returns following error
Error running callback:
Traceback (most recent call last):
File “<stdin>”, line 1, in <module>
File “<string>”, line 4, in <module>
AttributeError: ‘NoneType’ object has no attribute ‘eval’
Also noted the tutorial file supplied as a checkpoint also shows this error so how would I carry out this task of listing the folder directory.
best regards
Paulie Paul
Python error for listing directories
1836 2 0- Paul Robinson
- Member
- 1 posts
- Joined: April 2016
- Offline
- goldfarb
- Staff
- 3455 posts
- Joined: July 2005
- Offline
- huey_yeng
- Member
- 69 posts
- Joined: Nov. 2016
- Offline
Hmm I'm still new to Python but the error indicates there is no such as “eval” attribute as the hou.node seems to be pointing to “.”
To get the current node, you can use hou.pwd() and to retrieve the parameter (aka evaluate it) you need to use evalParm(“parameterthatyouwanttoretrieve”)
I'm trying to create a what if scenario as I don't have Houdini in front of me so here goes:
To get the current node, you can use hou.pwd() and to retrieve the parameter (aka evaluate it) you need to use evalParm(“parameterthatyouwanttoretrieve”)
I'm trying to create a what if scenario as I don't have Houdini in front of me so here goes:
import os buildings_node = hou.node(“/obj/buildings”) # We set the variable with the target node aka "/path/to/the/node" buildings_path = buildings_node.evalParm(“path_to_buildings”) # Here we retrieve the value of "path_to_buildings" parameter (make sure it exists in the first place) buildings_folder = os.listdir(buildings_path) # Use Python OS Module to list the directories print buildings_folder
-
- Quick Links