Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    sys.setrecursionlimit() in C4D 15 not working?

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 166 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      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  
        list.append(obj)  
        browse(obj.GetDown(),list)  
        browse(obj.GetNext(),list)  
        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!

      shirayuki

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        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
        linearly.

        def browse(obj, list) :
        	while obj:
        		list.append(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()
        
        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post