sys.setrecursionlimit() in C4D 15 not working?

On 07/10/2014 at 12:03, xxxxxxxx wrote:

Hi everybody,

i have a standard recursive function for browsing throw the c4d scene to get all objects.

def browse(obj,list) :  
  if not obj: return  
  if not list: return  
  return list  

Unfortunaly this does not work in R15 if a null group have more than 1500 polygon child objects (C4d just crash). Setting the recursion limit to 50000 with sys.setrecursionlimit(50000) does not seem to work.
All its fine in C4D R14.

Thanks for any help!


On 07/10/2014 at 14:37, xxxxxxxx wrote:

Ouch! Don't do it like that. You can go recursively for the next hierarchy level, but its absolutely
not required and not recommended for the same level where you can just iterate over all items

def browse(obj, list) :
	while obj:
		browse(obj.GetDown(), list)
		obj = obj.GetNext()

A hierarchy-depth of 1000 is rather rare so you should not run into problems with that.

PS: Generators are much more appropriate here.

def browse(obj) :
	while obj:
		yield obj
		for x in browse(obj.GetDown()) :
			yield x
		obj = obj.GetNext()

On 08/10/2014 at 01:51, xxxxxxxx wrote:

Hi Niklas,

thank you very much for the quick reply!!! 🙂
I should noticed that by myself, sorry!*idiot*

This was a part of an old script i wrote years ago.
Yesterday i was a little bit overworked.
I already use the function you suggest for browsing scene later on.
Now, my problem is solved. Thank you!!!

But i am still wondering why my (bad) recursive function is working in c4d r14 by setting the setrecursionlimit, but not in c4d r15.