Python_init.py

Introduction

Python code written in python_init.py is executed before all plugins registrations. c4d and maxon can be imported and used.

python_init.py location

For R20 and after python_init.py is located and loaded in this order:

  • Windows:
    1. %APPDATA%/MAXON/python27/python_init.py.
    2. %APPDATA%/MAXON/Cinema 4D R20_XXXXXXXX/python27/python_init.py.
  • MacOS:
    1. ~/Library/Preferences/MAXON/python27/python_init.py.
    2. ~/Library/Preferences/MAXON/Cinema 4D R20_XXXXXXXX/python27/python_init.py.

Warning

In R20 SP1 python_init.py is not loaded.

Before R20 python_init.py was located:

  • for Windows in %APPDATA%/MAXON/Cinema 4D R19_XXXXXXXX/prefs/python/python_init.py.
  • for MacOS in ~/Library/Preferences/MAXON/Cinema 4D R19_XXXXXXXX/prefs/python/python_init.py.

Variables

Few variables can be accessed in python_init.py

Note

In R20 SP2 python_init.py variables are not available.

They can be defined as below:
doc = c4d.documents.GetActiveDocument()
op = doc.GetActiveObject()
tp = doc.GetParticleSystem()