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

    Get PluginID from within CommandData plugin

    Cinema 4D SDK
    python r20 windows
    3
    4
    947
    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.
    • B
      Boony2000
      last edited by Boony2000

      Hi!

      Is it possible to get the pluginID of a CommandData plugin from within the registered plugin class/instance?
      I saw that BasePlugin.GetID() exists, but sadly it doesn't seem to work in a CommandData Plugin.
      I am looking for something like self.GetPluginID() to retrieve the ID from within the running plugin.

      Thanks!

      1 Reply Last reply Reply Quote 0
      • C4DSC
        C4DS
        last edited by

        I am somewhat confused by this question.
        Since you need the pluginID to register the CommandData, why would you want to obtain the pluginID from within the CommandData? I don't get it.

        1 Reply Last reply Reply Quote 1
        • M
          mp5gosu
          last edited by

          Me neither. If you defined it as global constant, you can access it from wherever you want inside your code.
          For foreign plugins, you can use GetFirstPlugin() and then iterate them and use GetID() to get their IDs.

          Like this:

          import c4d
          
          if __name__=='__main__':
              p = c4d.plugins.GetFirstPlugin()
              while p:
                  print "Plugin: ", p.GetName(),"/ ID: ", p.GetID()
                  p = p.GetNext()
          
          1 Reply Last reply Reply Quote 1
          • B
            Boony2000
            last edited by Boony2000

            I am trying to register multiple plugins that are instances of the same class, but do slightly different stuff (in this case construct different menus). I am getting some external data that I would like to put in a dictionary with the plugin ID as keys. I could then get the correct data set for each plugin by comparing the pluginID from e.g. within execute with the pluginIDs in the dictionary. But for that I would need a way to retrieve the pluginID of the class instance whose execute function was called.

            Edit: I figured out a way. I can pass the pluginID when initializing the plugin in the register function and save it as a class member in __init__

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