Mozzarino Posted January 25, 2021 Share Posted January 25, 2021 (edited) 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 January 25, 2021 by Mozzarino Quote Link to comment Share on other sites More sharing options...
Stalkerx777 Posted January 29, 2021 Share Posted January 29, 2021 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. Quote Link to comment Share on other sites More sharing options...
Mozzarino Posted January 30, 2021 Author Share Posted January 30, 2021 @Stalkerx777 You'r right, I was missing the exit() function in my code... completly forgot Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.