DougStruthers Posted October 3, 2017 Share Posted October 3, 2017 As Python frowns on goto lines, I am looking for a way to break out of a python script. return does not appear to work though I found an old 2013 suggestion. Quote Link to comment Share on other sites More sharing options...
f1480187 Posted October 3, 2017 Share Posted October 3, 2017 (edited) There are many different ways to do it in Python and HOM. You can wrap into a function and use returns in the body. Or raise descriptive errors and treat them differently. HOM has all sorts of custom errors too. This one will cook a node without errors. Depending on the input, it may show a warning and stop the script from executing further: node = hou.pwd() geo = node.geometry() pts = geo.iterPoints() if not pts: raise hou.NodeWarning('Input geometry has no points.') geo.addAttrib(hou.attribType.Global, 'number_of_points', len(pts)) Edited October 3, 2017 by f1480187 1 Quote Link to comment Share on other sites More sharing options...
acey195 Posted October 3, 2017 Share Posted October 3, 2017 the easy solution is to wrap the entire node of the sop in a function, like f1 already suggested def myfunction(): print "print this" return print "but not this" myfunction() #make sure you actually run your code at the bottom of course Quote Link to comment Share on other sites More sharing options...
acey195 Posted October 3, 2017 Share Posted October 3, 2017 (edited) -doublepost- Edited October 3, 2017 by acey195 removed double post Quote Link to comment Share on other sites More sharing options...
DougStruthers Posted October 3, 2017 Author Share Posted October 3, 2017 Thank you all. Really appreciated. 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.