SkillAgentSearch skills...

SendPythonCodeToCinema4D

Plugin for Cinema 4D that allows you to sent code from text editor to Cinema 4D and execute it.

Install / Use

/learn @MikeUdin/SendPythonCodeToCinema4D
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

SendPythonCodeToCinema4D

SendPythonCodeToCinema4D is a plugin for Cinema 4D that allows you to sent python script code to Cinema 4D and execute it. Plug-in based on Niklas Rosenstein's Remote Code Runner. Get it here.

Installation

Download the latest code from GitHub and unpack the content into your Cinema 4D plugin directory.

```
Cinema 4D RXX/
    plugins/
        SendPythonCodeToCinema4D/
            SendPythonCodeToCinema4D.pyp
            send_python_code.py

```
  

How to use

Use command line to send python script code to Cinema 4D:

cmd python -u "d:\Your Cinema 4D Plugins\SendPythonCode\send_python_code.py" --file "c:\\script.py"

or use full path to python executable:

cmd "c:\Python27\python.exe" -u "d:\Your Cinema 4D Plugins\SendPythonCode\send_python_code.py" --file "c:\\script.py"

By default the client now scans the port range and discovers the active Cinema 4D plugin by a lightweight handshake before sending code.

Text editor integration

You can use SendPythonCodeToCinema4D with different code editors like a Notepad++, Sublime Text or PyCharm.

Notepad++

Preview Image Open menu Run and write:

python -u "d:\Your Cinema 4D Plugins\SendPythonCode\send_python_code.py" --file "$(FULL_CURRENT_PATH)" --origin "Notepad++"

Setup run-command name and press Save. Now you can send code from opened for editing python script file to Cinema 4D. Also using Notepad++ NppExec plug-in you can send to Cinema 4D unsaved code. Install NppExec plug-in, open menu Plugins > NppExec > Execute and enter this code:

set TEMP_PATH = $(NPP_DIRECTORY)\temp_script.py
text_saveto "$(TEMP_PATH)"
python -u "d:\Your Cinema 4D Plugins\SendPythonCode\send_python_code.py" --file "$(TEMP_PATH)" --origin "Notepad++"

Sublime Text

Preview Image Open Tools > Build System > New Build system. Paste this code:

{
    "cmd": ["python", "-u", "d:\\Your Cinema 4D Plugins\\SendPythonCode\\send_python_code.py", "--file", "$file", "--origin","Sublime Text"],
    "selector": "source.python",
    "file_regex": "^\\s*File \"(...*?)\", line ([0-9]*)"
}

Save file with desired name. Then go to Tools > Build System and select already created Build system. To send code to Cinema 4D use command Tools > Build. Also for more convienient use you can setup shortkey.

PyCharm

Preview Image Go to menu File > Settings > Tools > External Tools. Setup Tool settings like this:

Name: SendCodeToC4D
Description: Send python code to Cinema 4D from PyCharm 
Program: python (or c:\Python27\python.exe)
Arguments: -u "d:\Your Cinema 4D Plugins\SendPythonCode\send_python_code.py" --file $FilePath$ --origin PyCharm
Working directory: $FileDir$

To send code to Cinema 4D use command Tools > External tools > SendCodeToC4D. Also for more convienient use you can setup shortkey.

Preview Image

Port discovery

When Cinema 4D starts, the plugin first tries the preferred port and if it is busy it scans the next ports in range until it finds a free one.

  • Default port range: 2900-2910
  • The plugin binds the first free port in that range.
  • The client scans the same range and sends a lightweight ping handshake until it finds the live plugin.
  • If you want a single fixed port, pass the same value to --port and --port-end.

You can override plugin defaults with environment variables:

  • SENDPYCODE_C4D_PORT_START sets the preferred starting port for the plugin.
  • SENDPYCODE_C4D_PORT_END sets the last port included in the scan range.

Client options:

  • --port sets the scan start port.
  • --port-end sets the scan end port.
  • --connect-timeout sets the per-port timeout used during discovery.

Execution results

The plugin now returns structured execution results back to the client.

  • Successful runs can print stdout back to your editor or terminal.
  • Python exceptions from Cinema 4D are returned in stderr.
  • Discovery now relies on the plugin handshake, so the updated client is intended to be used together with the updated plugin.

Advanced features

You can use SendPythonCodeToCinema4D also for editing Cinema 4D Python objects like a Python Generator, Python Effector, Python Tag and Python Field. For that use script code docstring:

To change code in Python generator use in docstring:

Generator: <Your python generator object name>

To change code in Python effector use in docstring:

Effector: <Your python effector object name>

To change code in Python tag use in docstring:

Tag: <Your python tag name>

To change code in Python field use in docstring:

Field: <Your python field object name>

Example:

After sending this code to scene all Python field objects with name "Python Field" will recive it.

"""
Python Field description

Author : Mike Udin
Web-site : mikeudin.net
Field : Python Field

"""
import c4d

def main():
	# code here
    pass

mikeudin.net

Related Skills

View on GitHub
GitHub Stars21
CategoryDevelopment
Updated8d ago
Forks1

Languages

Python

Security Score

75/100

Audited on Mar 27, 2026

No findings