How to make a Python Plugin...

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/Cinema4DPythonSDK/html/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://plugincafe.maxon.net/c4dpluginid_cp
        str="HelloWorld",
        info=0,
        dat=HelloWorldCommand(),
        help="put some Help test here...",
        icon=c4d.bitmaps.InitResourceBitmap(5126)
        )

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

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://plugincafe.maxon.net/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

@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

@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