Operating System: Windows Vista Home Premium, 32-bit
Graphics Card: ATI Radeon HD 2600 XT
Blender Versions Tested: 2.63.0 r46461 (official)
I have an operator that calls render.render('INVOKE_DEFAULT', animation=True). This operator is also appended to render_complete, so I can do several renders in succession. However, after the callback, render.poll() apparently has incorrect context, and therefore stops.
I noticed that if I just call render.render(animation=True), without invoking, it goes through the callback fine and does everything as it should. This, however, leads to locking Blender, and the UI completely freezes until all rendering is complete.
It doesn't matter if it's an operator or function, the render.poll() context is always incorrect, and it's always when I invoke it. This is not particular to this script, it always happens.
Basic flow:
- "op1" gets called and checks if everything in the rendering "todo" list has been done, if not...
- "op1" calls render('INVOKE_DEFAULT', animation=True), and when rendering is complete, "func1" is called again through the render_complete callback
So...
"op1" -> render -> render_complete -> "op1", etc...
It seems strange that invoking render() leads to render.poll() having incorrect context. It's also strange that calling render() as normal, without invoking, locks/freezes the UI.
I've tried looking through the C code to find the poll() function and work out what's going on, but I'm very new to C and have very little idea of what I'm looking at and should be looking for! :P
I had a quick check through the development todo list and found, under the Scripting category: "Using operators from python, in many cases won't work (when they could) or crash instantly." - the first listed issue here: http://wiki.blender.org/index.php/Dev:2.5/Source/Development/Todo/Scripting
So, this particular issue may already be known about. If so, sorry for "bugging" you. ;)
If this isn't a bug, and I've been missing something, then I'm very sorry! Especially if it's considered obvious! :) I really hope this can be solved, as I have two addons vertually ready to go that need rendering control.
Thank you for your replies and inspections in advance!
Description
Event Timeline
Regarding the call to render() blocking, this is intended behavior, the operator can be either invoked, in which case it will start the job in the background and not for it to finished. If this is not done, it will block until the render is done.
But further I don't really understand what you are doing, what "render_complete" is, etc. Bug reports should give us exact steps to redo the problem, in this case that would be a small script that we can run to see the issue.
Hiya,
I've attached an example .blend file which has a small commented script in the text editor. It's highly commented, so I hope the code doesn't get lost within it all! Also, sorry for not attaching a script initially, I should have done so!
Regarding the call to render(); seeing as clicking any render button in Blender doesn't block the UI, I assumed that this wasn't intended.
(I also noticed silly spelling mistakes in my initial post, oops!)
Thanks for the reply!
Hi,
What you are doing (calling an op from a handler) is not recommended, and it seems just not supported in this precise case.
I took some time and found a way to do what you want, using a modal operator periodically updated by a timer, and a very simple callback func to mark a render as finished, see the attached file.
As for the render op itself, as said Brecht, it’s by design that it is only modal when invoked (Render buttons & co do invoke it).
Anyway, no real bug here, just more or less known limitations, so closing now :)
Hi Bastien,
Firstly, sorry for wasting your time with this report!
Secondly, thank you for taking the time to look into it. I really appreciate the help. I've looked at and ran your script and it works a dream.
Again, sorry, and thank you!