Object GetNext() method does not advance to next object

We are using Arnold with C4D

While iterating the scene, we have found that one of the node (create via the ArnoldtoC4D plugin), the GetNext() method does not return the next object but itself, this resulted in an infinite loop iterating the scene.

Since we are now sitting between two different vendors, I am trying to narrow it down to who I need to follow up with regarding this issue.


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

Cheers

The line obj.GetNext() only returns the next object, but you don't assign it again... so obj stays at the same object forever. Try obj = obj.GetNext().

Hi @nicholas_yue,

@Cairyn said everything (thanks for that). I would additionally recommend to read the Wikipedia article on graph traversal I have posted in your other thread, as it might clear up a few things for you.

Cheers,
Ferdinand