I am writing some pipeline code that is traversing a C4D scene. The way I found in their documentation when iterating nodes in C4D scenegraph is via the object's GetNext() method.
However, when my code reach the <display driver> node that is created by the AOV editor in C4D for Arnold, the GetNext() method of that node does not point to the next node but point to itself resulting in C4D hanging.
Is this a known problem ? Is there a workaround ?
OUTPUT FROM C4D PYTHON CONSOLE
>>> doc = c4d.documents.GetActiveDocument()
>>> obj = doc.GetFirstObject()
>>> print(obj)
<c4d.BaseObject object called 'Arnold distant_light/Arnold Light' with ID 1030424 at 0x0000027ACD423D10>
>>> obj.GetNext()
<c4d.BaseObject object called '<display driver>/Arnold Driver' with ID 1030141 at 0x0000027ACD423AD0>
>>> obj.GetNext()
<c4d.BaseObject object called '<display driver>/Arnold Driver' with ID 1030141 at 0x0000027ACD423FB0>
>>> obj.GetNext()
<c4d.BaseObject object called '<display driver>/Arnold Driver' with ID 1030141 at 0x0000027ACD423DF0>
>>> obj.GetNext()
<c4d.BaseObject object called '<display driver>/Arnold Driver' with ID 1030141 at 0x0000027ACD423AD0>
>>> obj.GetNext()
<c4d.BaseObject object called '<display driver>/Arnold Driver' with ID 1030141 at 0x0000027ACD423FB0>
>>> obj.GetNext()
<c4d.BaseObject object called '<display driver>/Arnold Driver' with ID 1030141 at 0x0000027ACD423DF0>
>>> obj.GetNext()
<c4d.BaseObject object called '<display driver>/Arnold Driver' with ID 1030141 at 0x0000027ACD423AD0>
>>> obj.GetNext()
<c4d.BaseObject object called '<display driver>/Arnold Driver' with ID 1030141 at 0x0000027ACD423FB0>
>>> obj.GetNext()
<c4d.BaseObject object called '<display driver>/Arnold Driver' with ID 1030141 at 0x0000027ACD423DF0>
>>> obj.GetNext()
<c4d.BaseObject object called '<display driver>/Arnold Driver' with ID 1030141 at 0x0000027ACD423AD0>
>>>
Solved! Go to Solution.
Solved by peter.horvath6V6K3. Go to Solution.
Your code is not correct, you call GetNext() on the same object over and over. Check out this code which iterates over the top level objects in the scene:
import c4d from c4d import gui # Main function def main(): doc = c4d.documents.GetActiveDocument() obj = doc.GetFirstObject() while obj is not None: print(obj) obj = obj.GetNext() # Execute main() if __name__=='__main__': main()