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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    fill selection - bitmap

    Scheduled Pinned Locked Moved PYTHON Development
    11 Posts 0 Posters 851 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 27/07/2016 at 04:34, xxxxxxxx wrote:

      How I can get information about this error in cinema?
      RuntimeError: maximum recursion depth exceeded
      _
      _
      StackOverflow to the rescue! (no pun intended)

      http://stackoverflow.com/questions/3323001/maximum-recursion-depth

      It has nothing to do with Cinema.

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

        On 27/07/2016 at 05:23, xxxxxxxx wrote:

        Thank you Niklas

        I have already tried to increase setrecursionlimit but nothing has changed. Maybe I have to try to do some changes to the script as in the link.

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

          On 27/07/2016 at 08:28, xxxxxxxx wrote:

          Set or get the size of the image.
          Then loop through the pixels in the image and set their color values.

          import c4d  
          from c4d import bitmaps  
          def main() :  
              
            bmp = c4d.bitmaps.BaseBitmap()  
            bmp.Init(100, 100, 24)  
            for x in xrange(100) :  
                for y in xrange(100) :  
                    bmp.SetPixel(x, y, 255, 0, 0) #<--- Fills the image with Red  
                      
            bitmaps.ShowBitmap(bmp)    
              
            c4d.EventAdd()    
            
          if __name__=='__main__':  
            main()
          

          -ScottA

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

            On 27/07/2016 at 08:35, xxxxxxxx wrote:

            Originally posted by xxxxxxxx

            Thank you Niklas

            I have already tried to increase setrecursionlimit but nothing has changed. Maybe I have to try to do some changes to the script as in the link.

            It's likely that you have an infinite recursion going on.

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

              On 27/07/2016 at 11:27, xxxxxxxx wrote:

              Thank you all 🙂

              Bitmap: so I suppose that I have to get the coordinates of the polygon and to fill the space with the loop. I will try.

              Problem: the odd things (for me) is that it happens only when I run the script to an object that has many polygons. If I run it selecting an object with a lower number of polygons there is no error.

              thank you again 😉

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

                On 27/07/2016 at 11:47, xxxxxxxx wrote:

                Originally posted by xxxxxxxx

                Problem: the odd things (for me) is that it happens only when I run the script to an object that has many polygons. If I run it selecting an object with a lower number of polygons there is no error.

                thank you again 😉

                Sounds like you're using recursion for something that could be solved much more easily using iteration.
                If you want more concrete answers, share some code.

                Cheers,
                Niklas

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

                  On 27/07/2016 at 12:34, xxxxxxxx wrote:

                  ok. I will share the code soon.

                  thank you

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

                    On 28/07/2016 at 04:44, xxxxxxxx wrote:

                    This is the code that gives me the error when I use it on the object with many childrens.

                      
                    import c4d  
                      
                    def GoDownHierarchy(obj) :  
                      if obj is None: return  
                      myList.append(obj)  
                      if (obj.GetDown()) :  
                        GoDownHierarchy(obj.GetDown())  
                      if (obj.GetNext()) :  
                        GoDownHierarchy(obj.GetNext())  
                      
                    def main() :      
                      global myList  
                      myList = []  
                      myDoc = c4d.documents.GetActiveDocument()  
                      myObj = myDoc.GetActiveObject()  
                      if myObj is None: return  
                      GoDownHierarchy(myObj)  
                      print myList  
                         
                    if __name__=='__main__':  
                      main()  
                    

                    About the bitmap.
                    I have found the way to obtain the  UVW vector of the points of the polygon.
                    In the ScottA script the color is applied for each point of the bitmap like in a printer, but with 3-4 point (not a square) how can I define where the virtual printer has to apply the color?

                    Thank you 🙂

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

                      On 28/07/2016 at 04:59, xxxxxxxx wrote:

                      As Niklas already pointed out, you are having a problem with your recursion, which in the end will lead to a stack overflow.
                      Instead of walking the tree recursively, it's advised to have a loop for the "Next" direction and only recurse into the "Down" direction. I know, this link leads into the C++ docs, but I'm sure you can see the pattern in the second depicted code snippet.

                      I'm not sure, I understood the question about the "virtual printer". Scott is using SetPixel() and the function gets the coordinate of the pixel as parameters. There's no need to use the loops, if you know which pixels you are addressing. Or you could store the coordinates of relevant pixel in a list and then loop over this list to set the pixels. Many roads...

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

                        On 23/10/2016 at 01:59, xxxxxxxx wrote:

                        Sorry for the delay.
                        Thank you very much for all the suggestions. 🙂

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