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:
%APPDATA%/MAXON/python27/python_init.py
.
%APPDATA%/MAXON/Cinema 4D R20_XXXXXXXX/python27/python_init.py
.
- MacOS:
~/Library/Preferences/MAXON/python27/python_init.py
.
~/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
doc:
BaseDocument
: The document.op:
c4d.BaseObject
: The Object selectionned. Can be None.tp:
c4d.modules.thinkingparticles.TP_MasterSystem
: The Thinking Particle Master system of the document. Can be None.
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()