c4dpy

c4dpy.exe/app is an executable that runs Cinema 4D in Python command-line mode.
It is not only an interpreter, it brings extra features for daily Python development with external code editors/IDEs: auto-completion and debugging.

Install

Warning

c4dpy needs a valid installation of Cinema 4D it’s not a standalone.

Note

c4dpy should have the same version than the folder is in it.

R21:

With R21 c4dpy is part of the normal installation process so you don’t need to install anything.
However due to the new licensing system, before any usage of it, launch it at least one time in order to license c4dpy otherwise you can pass these argument while executing c4dpy:
  • g_licenseUsername=”[username]”// inform Cinema 4D about the username to authenticate on https://id.maxon.net.
  • g_licensePassword=”[password]” // inform Cinema 4D about the password to authenticate on https://id.maxon.net.

R20:

  1. Download the c4dpy version which match your Cinema 4D version.
  2. Extract the c4dpy executable according to the target operating system.
  3. Copy the extracted c4dpy executable to the Cinema 4D installation directory along with the other executable files:
../../_images/c4dpy_installdirectory.png

Verify Install

Windows

  1. Open Command Prompt.
  2. Drag c4dpy.exe executable into the Command Prompt and press enter.
  3. c4dpy should run without error and ask your MyMaxon account. Next start you will not need to login again.
  4. Python interactive interpreter >>> is now available.

Mac

  1. Open Terminal.
  2. Right-click on c4dpy.app and select Show Package Contents.
  3. Navigate to the Contents/MacOS directory.
  4. Drag the c4dpy file into the Terminal window and press return.
  5. c4dpy should run without error and ask your MyMaxon account. Next start you will not need to login again.
  6. Python interactive interpreter >>> is now available.

Editor/IDE Setup

Note

This section shows how to add c4dpy interpreter to code editor and IDE softwares.
The screenshots may not reflect changes in future versions of these programs but the steps should remain the same.

Visual Studio Code

Warning

Due to a bug, Visual Studio Code, is not anymore supported for c4dpy R21.
For more information see c4dpy.exe and VS Code.

Windows

  1. Install the Python extension for Visual Studio Code.
  2. Select the File > Preferences > Settings command (or Ctrl + , shortcut).
  3. Search the settings for python.pythonPath and set it to point to the full path of the c4dpy.exe file. For example:
../../_images/c4dpy_vscode_win.png

The Python Path is set in the User Settings so c4dpy.exe interpreter is used globally by Visual Studio Code.

Note

Settings can be specified by user, workspace or folder.

  1. Restart Visual Studio Code.

Note

With c4dpy version R20 SP1, debugging fails because ptvsd module cannot be found. The Python extension for Visual Studio Code uses this module to debug.
The workaround is to copy the ptvsd module folder from the Visual Studio Code user preferences to C:Users{username}AppDataRoamingMAXON{cinemaversion}python27libs.

Mac

  1. Install the Python extension for Visual Studio Code.
  2. Select the Code > Preferences > Settings command (or Cmd + , shortcut).
  3. Search the settings for python.pythonPath and set it to point to the full path of the c4dpy Terminal file. For example:
../../_images/c4dpy_vscode_mac.png

The Python Path is set in the User Settings so c4dpy interpreter is used globally by Visual Studio Code.

Note

Settings can be specified by user, workspace or folder.

  1. Restart Visual Studio Code.

Note

With c4dpy version R20 SP1, debugging fails because ptvsd module cannot be found. The Python extension for Visual Studio Code uses this module to debug.
The workaround is to copy the ptvsd module folder from the Visual Studio Code user preferences to /Users/{username}/Library/Preferences/MAXON/{cinemaversion}/python27/libs.

Command-Line

c4dpy runs a script with:

c4dpy script.py

The following command invokes script.py and passes arg argument:

c4dpy script.py -arg

Note

Arguments can be accessed by sys.argv.

The command below loads the module in file.py and passes arg argument:

c4dpy -m file.py -arg

c4dpy also executes Python code in a string:

c4dpy -c "print('Hello')"