How to break from code?


(RipSting) #1

I’m having a problem with one of my scripts. It runs every time onFrameChanged, even when it doesn’t need to (such as when I hit the render button more than once while it’s on the same frame). Therefore I’ve written an if statement like this:

if oldFrame = Blender.Get('curframe'):
...print "no need to redraw."
...sys.exit()
oldFrame = Blender.Get('curframe')

However, sys.exit() closes totally out of Blender, which is not what I want.

I’ve also tried

raise SystemExit

But this also does the same thing.

Is there a way to simply break out of my code without having to make a huge ass if statement around my 500 lines of code? I’d rather not make things more complicated by having to do that. And indenting all those lines would be a pain, although I could export into MSword or something…


(d0pamine) #2

Hi,

Did you try ‘return’?

Tom