C4D 23 and Visual Studio Code Problem

  1. What I intended to do:
    I intend to write C4D scripts in VS Code.

  2. What I did to achieve:
    I was following the link edited by m_adam:

https://developers.maxon.net/docs/Cinema4DPythonSDK/html/manuals/introduction/autocompletion_dummy_package.html

done with Installation 1 and 2, and already put c4d libs shortcut into "site-packages" folder.
0588a0ec-5c1e-4ffe-bf44-8e5c90a88a11-image.png

3.What happened and needed to be solved:

I tried python3.8.5 & 3.7.9 both 64-bits but none of them worked plus return message below:

dca7f3fb-eed5-434f-9cd4-8386f06c3e8a-image.png

--------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
e:\VS_Code_Prjs\C4Dtraining\oops in 
----> 1 import c4d
      2 from c4d import utils

~\AppData\Local\Programs\Python\Python38\lib\site-packages\c4d\__init__.py in <module>
     27 from .symbols import *
     28 
---> 29 from .functions import *
     30 
     31 from ._internal_doc_utils import MAXON_DOC_INTERNAL_ADDITIONAL_INFO

ModuleNotFoundError: No module named 'c4d.functions'

So in my opinion, it first run the init.py then find no existence of modules name "c4d.functions" or "c4d.symbols",
but in Cinema 4D Console it never asks me about c4d.functions or c4d.symbols.
And this is really hard for me to solve.
How to solve these and make VS Code work well with c4d?

Hi @PATPAT,

thank you for reaching out to us. It is not fully clear to us what you are trying to do. The autocompletion dummy package is documented in the Cinema 4D Python SDK documentation. Its purpose is however exactly that: To feed an autocompletion engine (.e.g., IntelliSense in VS Code) by providing a fake package to feed such an engine with information.

The autocompletion dummy package is not a library that you can import into a Python instance of your choice. Judging by your screenshot you are trying to do that, importing the c4d module while running an IPython instance. To run Cinema 4D Python code outside of Cinema 4D you have to use our Python interpreter c4dpy instead. We have also have a short documentation for c4dpy. For VS Code @m_adam has described here how to configure VS Code to run c4dpy as its debugging environment (you have unfortunately rename c4dpy.exe for that - due to how VS Code works). For Sublime Text you just need a build environment like this:

// Named c4dpy.sublime-build
// Instead of the full path you could also just register a path variable for `c4dpy`
{
    "cmd": ["{PATH_TO_CINEMA4D_FOLDER}/c4dpy.exe", "-u", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python"
}

You can of course also just run c4dpy in a terminal directly.

In case I did misunderstood your goals, I would have to ask you to restate what you are trying to achieve. Otherwise I hope this helps to get c4dpy running in a code editor of your choice.

Cheers,
Ferdinand

Oh, it seems i misunderstood autocompletion dummy package. I thought I could edit c4d script anywhere with configured VS Code:P, anyway very thanks to you !

Hi @PATPAT,

you can do it, you just cannot use the dummy package for it, but have to use the c4dpy interpreter instead.

Cheers,
Ferdinand