Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Calling a Python plugin from C++ PluginStart()

    Cinema 4D SDK
    r21 c++ python
    2
    4
    643
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • fwilleke80F
      fwilleke80
      last edited by fwilleke80

      Hi all,

      is it possible to call a Python plugin (.pyp) from within a C++ plugin's PluginStart()?
      In which order are modules and plugins initialised on application startup?

      I am trying to call a Python plugin from C++ PluginStart(), and I do not get an error. However, the plugin I call doesn't react either. My guess is that Python is already initialised, but the Python plugin I want to use has not been loaded yet.

      Is there a way to set a Python plugin's init priority? In the C++ SDK, a function called "SetPriority();" is still mentioned, but not documented anymore. In Python, it doesn't seem to exist. The C4DPL_INIT_ constants are still there.

      If I call the Python plugin from PluginMessage w/ C4DPL_STARTACTIVITY, it works. But I would really like to call the Python plugin before the C++ plugins are being registered.

      thanks & greetings,
      Frank

      www.frankwilleke.de
      Only asking personal code questions here.

      1 Reply Last reply Reply Quote 0
      • M
        m_adam
        last edited by

        Hi @fwilleke80, unfortunately, it's not possible since python in Cinema 4D is by design only a reflexion of C++. So by design python plugin are loaded after all plugins.

        May I ask you why you need such a python call as early as that?

        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        1 Reply Last reply Reply Quote 0
        • fwilleke80F
          fwilleke80
          last edited by fwilleke80

          I'm using a Python plugin to make HTTP requests on our update and activation server. The idea was to have it check for updates and valid license before the actual plugins get registered.

          And yes, I could write the request part in C++, but supporting R16 to R21 would mean a lot of work in C++, while the same Python code works across all these releases.

          Cheers,
          Frank

          www.frankwilleke.de
          Only asking personal code questions here.

          1 Reply Last reply Reply Quote 0
          • M
            m_adam
            last edited by

            If it's only a question of executing python, why not directly execute python from C++ using the python library?

            #include "c4d.h"
            #include "lib_py.h"
            PythonLibrary pylib;
             
            pylib.Execute("import c4d\nprint 'From Python:', c4d.GetC4DVersion()"_s);
            

            Note that in R20 the python.framework was released, and should be used for the future.
            The old python library (since R15) is still there and still works, but take care that in a future release it may disappear since everything that was possible and even more is now possible with the python.framework.

            For more information see Python Page.

            Cheers,
            Maxime.

            MAXON SDK Specialist

            Development Blog, MAXON Registered Developer

            1 Reply Last reply Reply Quote 0
            • First post
              Last post