Jump to content

Stop executing code with warning: python inside Houdini


Mozzarino

Recommended Posts

I'm using an if condition in my script to validate the existance of a directory. In case it doesn't exist, I want Houdini to stop execuing the code and raise a warning.
So far I have:
if (condition == False):

    raise hou.NodeError("No Source Folder Found.")
    exit()

But it seems like houdini is ignoring the raise warning function...

EDIT: Looks like the correct function for this is hou.ui.displayMessage("No Source Folder Found."), but it still runs the rest of the code which is not what I want...

Edited by Mozzarino
Link to comment
Share on other sites

There is no way for Houdini to continue executing your code after an exception raised, you must be doing something wrong. Paste your code here so we could check.

There are nuances in a way how Houdini handles Python exceptions depending on where the code is being executed. For example if you run some code from a shelf button, than expect it to behave as you would with normal Python except that exceptions won't terminate Houdini process. However if you put a Python expression in a parameter and it raises an exception, it will only stop execution of that parameter code, while the other parameters expressions on different nodes will continue to execute. Similar when you run code in batch mode (Hython) exceptions risen in parameter callbacks won't terminate, you have to take extra care to check for errors and manually call exit()

On 1/25/2021 at 9:48 AM, Mozzarino said:

EDIT: Looks like the correct function for this is hou.ui.displayMessage("No Source Folder Found."), but it still runs the rest of the code which is not what I want...

This function just pops up a message to the users and won't prevent your code from continue, check out the docs for it.

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