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.
So the database went wonkers again a while ago - unnoticed by your’s truly for quite a while. It was time to reduce that point of failure and go “old school”. The blog is now running from plain HTML with no backend. I am using Pelican. to generate the blog. It’s written in Python and easily adjustable and supports plugins. Unfortunately I’ve lost the old comments with this switch and there is no option to have blog comments right now.
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.
I think it is pretty safe to say that Python has become the mostly widely adopted scripting language across many, many CG and VFX applications. A few years back almost every tool had its very own choice of scripting language. They pretty much still exist and from pure history they are still heavily used for existing tools or just for the fact that developers, TDs and artists rely on them because they know them well.