Navigation

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

Search:

 

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()
while(obj):
   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.

Category:Scripting

Categories: