Console not updating anymore for debugging
-
On 29/04/2015 at 08:02, xxxxxxxx wrote:
Hi
This is an odd one.
Until just recently I would use the console to display data while executing a python generator script. I would have some loops with intensive cpu work going on - and I would update the console with some print commands to show where in the loop it is, and print other useful data. This would show me in realtime how the script is progressing as it's being executed.But for some reason this has suddenly stopped. I now only get the print out of data in one lump sum after the script has completed, and not during execution. I can't remember changing any settings, or changing anything in my code that would cause it. Totally dumbfounded. Any help appreciated, thanks,
Glenn. -
On 29/04/2015 at 08:24, xxxxxxxx wrote:
Hi Glenn,
just a wild guess...
Did you try to open a new scene with a new generator object and copy/paste the code.
A few days ago I had some issues with a generator, too and a new scene solved it.
Best wishes
Martin -
On 29/04/2015 at 08:57, xxxxxxxx wrote:
Na, just tried that Martin - copied everything into a new scene file, created new generator.. no luck. strange one..
-
On 29/04/2015 at 11:10, xxxxxxxx wrote:
where is your print statement placed?
Is it after you return the cache? Did you handle the cache optimization by yourself?
A snippet will help to dive into.Best wishes
Martin -
On 29/04/2015 at 11:38, xxxxxxxx wrote:
just found the source of the problem - it's to do with the EventAdd lines I have in my code. Below I've recreated the problem - 'hit' is printed after the code has completely executed. Take out the eventadd line and it's printed half way through as expected.
import c4d
#Welcome to the world of Pythonc = 0
for x in xrange(1000000) :
cube = c4d.BaseObject(c4d.Ocube)
if c==50000: print 'hit'
c += 1
c4d.EventAdd()
print 'done'
def main() :
return -
On 30/04/2015 at 07:42, xxxxxxxx wrote:
Hello,
calling EventAdd() inside the loop does not make sense. This function adds an event to an event queue that is evaluated after your code is left. Also adding multiple events will result in only one update.
If the presence of EventAdd() influences the work of "print" it might be a bug. We will investigate.
Best wishes,
Sebastian -
On 30/04/2015 at 08:36, xxxxxxxx wrote:
Thanks,
In my actual program (not the example above) the eventadd wasn't inside the loop - it was in the root level of the script after the loop had finished, but was still causing the problem. I needed the eventadd to update my scene after materials where added to objects. Anyway, I got around all this and things are working okay without eventadd anywhere, cheers.