Community
Arnold for Cinema 4D Forum
Rendering with Arnold in CINEMA 4D using the C4DtoA plug-in.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

C4D : GetNext() node travesal - infinite loop

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
nicholas_yue
271 Views, 2 Replies

C4D : GetNext() node travesal - infinite loop

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

Tags (1)
Labels (1)
2 REPLIES 2
Message 2 of 3

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()
Message 3 of 3
nicholas_yue
in reply to: nicholas_yue

Got it. Thanks.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report