execute_python_script
Run custom Python code in Cinema 4D to access the full c4d API for complex scene manipulation, animation, and MoGraph operations when other tools fall short.
Instructions
Execute a Python script in Cinema 4D's Python environment.
This is the most reliable tool for non-trivial operations — it gives full access
to the c4d API and avoids wrapper/schema mismatches that can affect other tools.
Args:
script: Python code to execute in Cinema 4D. Has access to `c4d` and
`c4d.modules.mograph` modules.
Important usage notes:
- For animated/MoGraph data, always call doc.ExecutePasses() after SetTime():
doc.SetTime(c4d.BaseTime(frame, fps))
doc.ExecutePasses(None, True, True, True, c4d.BUILDFLAGS_NONE)
- For MoGraph/effector data, iterate frames sequentially (0..N) rather than
jumping directly to a later frame — sequential stepping produces more
faithful results.
- Security restrictions block certain keywords: import os, subprocess, exec(, eval(.
Keep scripts within the c4d API surface.
- For heavy operations (dense frame loops, complex MoGraph scenes), split work
into multiple smaller scripts rather than one large monolith.
- Use print() to return results — output is captured and returned.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| script | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |