Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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

    How to make a Python Plugin...

    Cinema 4D SDK
    python
    3
    5
    1.5k
    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.
    • N
      noseman
      last edited by

      I always wanted to be able to convert Scripts to Plugins but didn't know how. Thanks to some great people, here is the bare minimum code required to make a Cinema 4D Python Plugin.
      Save this as a .pyp file, and put it in a folder in the Plugins. It should appear in the Extensions menu.
      Mind you, this ONLY functions like a Script, click-run-done. No UI, no Attributes, nothing...

      There's a ton of other stuff you can read here:
      https://developers.maxon.net/docs/py/2023_2/misc/pluginstructure.html

      import c4d
      from c4d import gui
      
      class HelloWorldCommand(c4d.plugins.CommandData):
          def Execute(self, doc):
      
              #Put your executable Code here...
              c4d.gui.MessageDialog("Hello World!")
      
              return True
      
      if __name__ == "__main__":
          c4d.plugins.RegisterCommandPlugin(
              id=1059500, #Get Unique ID from https://developers.maxon.net/forum/pid
              str="HelloWorld",
              info=0,
              dat=HelloWorldCommand(),
              help="put some Help test here...",
              icon=c4d.bitmaps.InitResourceBitmap(5126)
              )
      
      mikeudinM 1 Reply Last reply Reply Quote 1
      • ferdinandF
        ferdinand
        last edited by

        Hello @noseman,

        Thank you for posting this. Readers should however keep in mind that this code snippet is bound to a plugin id (1059500) and therefore can only be registered once per Cinema 4D installation. To ship scripts to other users or to have multiple scripts packed up in this form, users must register a plugin each time they implement this skeleton.

        Cheers,
        Ferdinand

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 0
        • mikeudinM
          mikeudin @noseman
          last edited by mikeudin

          Thank you @noseman!

          @noseman said in How to make a Python Plugin...:

          convert Scripts to Plugins

          There is a nice solution to make it easy
          https://developers.maxon.net/forum/topic/10699/14153_c4d-prototype-to-plugin-converter

          Also a lot of Cinema 4D plugins examples for different cases are presented here
          https://github.com/PluginCafe/cinema4d_py_sdk_extended/tree/master/plugins

          Checkout my python tutorials, plugins, scripts, xpresso presets and more
          https://mikeudin.net

          N 1 Reply Last reply Reply Quote 0
          • N
            noseman @mikeudin
            last edited by

            @mikeudin Have you managed to make the plugin converter work with the latest versions?
            One of the reasons I started this thread was that I couldn't... hopefully it was some error I made.
            If you have some information, please share.
            Cheers

            1 Reply Last reply Reply Quote 0
            • mikeudinM
              mikeudin
              last edited by

              @noseman seems that it's needs to be updated
              https://github.com/nrosenstein-c4d/c4d-prototype-converter/issues/52

              Checkout my python tutorials, plugins, scripts, xpresso presets and more
              https://mikeudin.net

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