On 18/08/2013 at 07:41, xxxxxxxx wrote:
I have a problem which I keep stumbling upon when at varying stages when working on python elements within my scene. I have had this problem with both python xpresso nodes and python tags.
My understanding is that if either object(node or tag) has 'Frame Dependent' disabled, the script should only execute when the scene is updated in one way or another e.g. view port redraw or value change somewhere etc(please let me know if I have misunderstood this). The majority of the time this is how it operates, however sometimes the script will just keep executing again and again and won't stop, then when I try to change something in the code, the changes are not accepted and the script keeps running as if unchanged.
Has anyone else encountered this problem? Anyone know how to fix it?
I'm very much hoping this is me missing something and not a bug, any help would me much appreciated.
On 18/08/2013 at 07:57, xxxxxxxx wrote:
Sounds like you are calling c4d.EventAdd() in your tag. Could you post the code?
On 18/08/2013 at 08:03, xxxxxxxx wrote:
1. the infinite loop is more likely caused by your code. such fundamental errors are usually not in the c4d code.
2. enabling 'frame dependent' will ensure that your tag is only executed once per frame. a tag can appear multiple times in the expression queue for a pass/frame.
3. post your code.
On 18/08/2013 at 08:17, xxxxxxxx wrote:
Thanks, that was exactly it, it's astonishing I've managed to get as far as I have with python without realising this. - my script was unconditionally calling c4d.EventAdd() an the very end of the script.
Btw, I'm the same guy that tweeted you about your python lessons poll on Friday, just to bridge the link.
Thanks for the input littledevil, all of my loops have a finite number of iterations and so I didn't think it was that. Also my code is such a mess at the moment it would require some tidying before I could post if for someone to understand without ambiguity.
Thank you both!
On 18/08/2013 at 08:55, xxxxxxxx wrote:
you figured it right, calling c4d.EventAdd() unconditionally is the fault. It triggers an immediate refresh
and leads to an infinite loop. However, calling c4d.EventAdd() from a Tag is not always bad. This is
useful if you change a parameter on your Tag and you want to give immediate feedback to the user.
This technique is applied when treating boolean parameters as buttons. The only drawback
with this technique is, that the code is still not executed from the main thread and any GUI
operations are prohibited.
def main() :
if op[c4d.ID_USERDATA, 1]:
op[c4d.ID_USERDATA, 1] = False
# Do an action
I see, Adam, thanks for the hint. Good to know.