fill selection - bitmap
-
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.
-
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.
-
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
-
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.
-
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
-
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 -
On 27/07/2016 at 12:34, xxxxxxxx wrote:
ok. I will share the code soon.
thank you
-
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
-
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...
-
On 23/10/2016 at 01:59, xxxxxxxx wrote:
Sorry for the delay.
Thank you very much for all the suggestions.