A new version of Cineversity has been launched. This legacy site and its tutorials will remain accessible for a limited transition period

Visit the New Cineversity


 ·   Wiki Home
 ·   Categories
 ·   Title List
 ·   Uncategorized Pages
 ·   Random Page
 ·   Recent Changes
 ·   RSS
 ·   Atom
 ·   What Links Here



Create or Find Page:


View Python: Looping

The easiest way to loop is with a for statement:

for obj in doc.GetActiveObjects():
    print obj


You can also use a while loop:

obj = doc.GetFirstObject()
   print obj.GetName()
   obj = obj.GetNext()

When using a while loop, be very careful to ensure that all the code paths either break or update the test object (obj=obj.GetNext()) - otherwise it’s very easy to create an infinite loop that will cause C4D to hang.