Struggling with Python Documentation and pyc4d



  • Hi there,
    I'm trying to write a python plugin and keep hitting walls.
    My biggest problem is understanding the python api documentation with my limited knowledge of C++ (Done some OpenCl and small C++ project at uni, no knowledge of bigger software architecture).
    Usually example projects is all I need to get started with other software APIs, but C4Ds plugin examples on github are pretty useless to learn from for me. (Not even a single line of comment!?)

    Where does the "res" folder come from, what is it? Can't find a single trace about it in the python docs apart from this. Which is not comprehensible for me having grown up in the python world...

    Secondly I can't get CLion to like the .pyp file ending to make syntax highlighting work. (I don't get it. It is just python, aka 'If it looks like a duck, sounds like a duck... Would make live easier with editors.).
    And even if the plugin loads in C4D natively, pyc4d just gives me "EnvironmentError: cannot find pyp file - plugin registration failed".

    All in all the python API is for me just a horrible experience after knowing pymel, maya cmds and maxscript, which makes me sad. The python api documentation gives me the feeling to only cater C++ plugin developers and does nothing to give an artist with basic programming skills an introduction into a more "tech artisty" life in cinema 4D.

    I really don't like having to write those words, but I grew up with Cinema 4D and it was my introduction and part of the reason to pursue a degree in VFX and computer graphics. And it saddens me to say that these experiences drive me more and more into the world of Houdini and Blender...

    Grüße,
    Magnus



  • The res folder is located in the same location as your pyp file. It is described in the link you mentioned in the Directory Structure section.

    A res folder contains the UI code for the plugin. These are resource files (.res) for descriptions and dialogs as well as the strings used in these. I am not sure if these are described in the python docs but you can find the info in the C++ help files.

    Resource Files:
    https://developers.maxon.net/docs/Cinema4DCPPSDK/html/page_manual_resource_files.html

    Description files:
    https://developers.maxon.net/docs/Cinema4DCPPSDK/html/page_description_resource.html

    Dialogs:
    https://developers.maxon.net/docs/Cinema4DCPPSDK/html/page_dialog_resource.html

    Have you gotten the examples python scripts to work in C4D? I made a video for R17 a while back which may help.

    https://www.c4dcafe.com/ipb/forums/topic/99368-plugin-development-videos/?tab=comments#comment-677450

    For R20 you may need to put the SDK files in your own plugins folder, which you define from the Edit->Preferences->Plugins in C4D.

    Once you get the examples going then you can start editing them live and then in C4D you can press the Plugins->Reload Python Plugins button.

    The support team I am sure will jump into this thread and help you out.

    My advice would be to start with a Command Plugin. But for the life of me I can't find you a good example of that either.

    I will leave this up to the python guys here in the forum and the support team to help you out further.

    Hope some of this info is of use to you. Good luck!


  • Global Moderator

    Hi @sungam, first of all, welcome in the plugincafe community and thanks a lot for your feedback. I know these words will not help you but we are currently working to improve our Python Documentation and examples as well.

    With that's said, I know documentation should be sufficient, but MAXON offers free support for developers at plugincafe. So please contact us when you are in trouble, don't know where to look at or even get SDK issue.

    1. res folder is a specific folder where resources needed for your plugin are stored. (e.g. you develop an ObjectData plugin(a new object, like a cube), this cube get a description (a set of parameters, which make a description of the actual object representation), so you need to define theses descriptions within the res folder. Same thing for string and so on...).

    2. Clion is actually a C++ IDE, JetBrains offer Pycharm which is also supported by c4dpy. See C4DPY manual we cover how to setup Pycharm with c4dpy.

    3. "EnvironmentError: cannot find pyp file - plugin registration failed". I'm not sure to understand this, this error comes from c4dpy? Is it possible to get your current plugin, at least the code of your pyp file?

    If you have any questions, please open a new thread, in plugincafe we prefer to have one topic per thread so we can focus only into this specific issue and don't screw conversation, it's also easier for other peoples to find information.

    Do not hesitate to explain to us your project, so we can guide you (help us, to help you 😉 ).
    If it's something you don't want to disclose you can always reach us at sdk_support@maxon.net.

    Cheers,
    Maxime.