Jump to content

Avoid error when force cook in HDA


csp

Recommended Posts

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "opdef:/csp::Driver/wedge::1.0?PythonModule", line 19, in fixchan
  File "/mill3d/server/apps/SIDEFX/linux-x86-64/hfs13.0.545/houdini/python2.6libs/hou.py", line 24414, in cook
    return _hou.Node_cook(*args, **kwargs)
OperationFailed: The attempted operation failed.
Error while cooking.

This is the error I am getting when I hou.pwd().cook(True)

 

Why is that and how can avoid it?

 

thanks

Link to comment
Share on other sites

This is because your node is erroring in general.  Check hou.Node.errors() to see why it can't be cooked.

 
Thanks for the reply Graham. When I am not forcing the node to cook through hdaModule there is no errors, when I am forcing it to cook manually (lock/unlock) there is no errors again.
 
There is a warning coming from the following function and I am using the cook() to clear it. Is there any better way?
 
# Fix wedge channels and check if valid
def fixchan(pwd,parm):
    p = parm.getReferencedParm()
    value = parm.evalAsString()
    if p == parm:
        if value:
            if not hou.parm(value):
                hou.ui.setStatusMessage('This parameter does not exist. Please check the path again or Paste Copied [Relative] Reference.', hou.severityType.Warning)
                parm.set('')
                return False
            else:
                p = hou.parm(value)
        else:
            return False
    else:
        parm.setExpression('') # overwrite
        parm.deleteAllKeyframes() # clear parameter
        parm.set(p.path()) # set path to parm
        #hou.pwd().cook(force=True) # force cook to clear warning

This callback function on string parameter for channel path. You can either added manually and it will check if this path is valid or you can Paste Copied [Relative] Reference of channel and it will convert the `ch("../path/to/channel")` to string 

/obj/path/to/channel.

 

The reason I am using this is because I can read an expression inside `` with parm.expression(), I can't even overwrite it with parm.set(''). Thats why I setExrpession and then deleteAllKeyframes to clear parameter and add the path to references channel. That gives me a warning on the node (red zebra): 

unable to evaluate expression

But it does the job and as I said before manually forcing to cook will clear the warning.

Link to comment
Share on other sites

Have you tried puttting a try/except around the cook statement?(line #19)? That is where the error is occuring. If it fails return False. You will have at least overwritten and cleared the parameter.

 

It may be a timing issue. An event being issued at the wrong time means the cook can't possibly happen at that time. By trapping for the error you might be able to avoid that state and pick it up on the next event...?

Edited by Atom
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.

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