One thing you will do over and over again in scripting Cinema 4D is to go through your scene. Usually you go hunting for certain objects, tags or materials. This is pretty straight forward using the BaseList2D class methods by using GetNext() and GetDown() but can get old pretty fast as you are doing the same checking and safeguards over and over again. Python - like many modern programming languages - has a neat iterator pattern that is engrained into the language.
Now that we have had a short glimpse on the basics in the first article lets move on to do something meaningful. So far it has been a purely academic discourse. Usually, we want a script to do something with the objects we have in a scene. So the first step is to look at how we can access the scene file and go through selected objects and perform Cinema 4D commands on them.
The Python integration into Cinema 4D is quite thorough. There are several places where you can use Python to script and Python is integrated as a first class citizen with the same level of access like Cinema 4D’s internal scripting language COFFEE as well as the C++ API. There are different places in which you can use Python: as Python Script as Python Generator as Python Tag as Python Xpresso Node as Python Plugin As you can see, there are plenty of options to use Python in Cinema 4D.