Jump to content
art3mis

NameError: name 'hou' is not defined

Recommended Posts

Can any Python experts tell me why I get

Quote


  File "hou.session", line 9, in <module>
NameError: name 'hou' is not defined

with the following script entered in the Python Source Editor?

def set_opencl(parent_node, parm_value):
    for node in parent_node.allSubChildren():
        for p in node.parms():
            if p.name()=='opencl':
                try:
                    p.set(parm_value)
                except hou.PermissionError: #this handles the case that the parm is inside of a locked .otl
                    pass
hou.session.set_opencl(hou.node('/obj/sim'),1);

Houdini 16.0.597 Indie in Linux

Edited by art3mis

Share this post


Link to post
Share on other sites

The last line shouldn't go into the session module.  You should type it into a python shell to use that function from the session module.

It also shouldn't have a semicolon at the end.

Share this post


Link to post
Share on other sites

 That is a long-standing "bug", if you didn't put import hou  in hou.session module, it will work until first error (any python exception), once you get an error, hou module gets lost for some reason. So, just always do import hou.

 

Edited by Stalkerx777

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×