Hi @Yaroslav this is indeed possible however a bit clunky for the moment, but here a full step by step.
Install pip with c4dpy -m ensurepip
Install Python Visual Studio Debugger with c4dpy -m pip install ptvsd.
Within Visual Studio in your launch.json just set up a basic attach setting, here is mine but for more information see
Python debug configurations in Visual Studio Code.
{
"version": "0.2.0",
"configurations": [
{
"name": "Cinema 4D: Remote Debugger Attacher",
"type": "python",
"request": "attach",
"connect": {
"host": "127.0.0.1",
"port": 3000
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "."
}
]
},
]
}
The *.pyp plugin should be of course in the same workspace as your launch.json.
Edit the *.pyp plugin and write the next code in the first line of your pyp file.
import ptvsd
ptvsd.enable_attach(address = ('127.0.0.1', 3000))
Start Cinema 4D, wait until its UI is loaded, meaning the pyp plugin is loaded, and the client (your script) is attachable from a debugger.
Run the previously created debug configuration (called Cinema 4D: Remote Debugger Attacher).
Put a breakpoint somewhere (like in the Execute of a CommandData) to trigger the BP.
Enjoy
Note this also works nicely for the script, however for script you should call ptvsd.wait_for_attach() after the ptvsd.enable_attach.
Cheers,
Maxime.