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

    Calling CommandData by name

    Cinema 4D SDK
    c++ python r19 r20
    2
    5
    1.2k
    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.
    • rsodreR
      rsodre
      last edited by r_gigante

      Hi!

      I'm writing a C++ CommandData plugin that I call from Python with c4d.CallCommand(1000010)

      Is there any way to give it a name and call it by the name? I think GetScriptName() should do it but there's no info on how to use the name.

      1 Reply Last reply Reply Quote 0
      • a_blockA
        a_block
        last edited by

        Hi,

        as far as I understand, you would like to be able to do a CallCommand(ID_MYCOMMANDPLUGIN) instead of a call with the numeric value, right?
        Unfortunately this is not possible, as the symbol parser does not scan the plugins. So you will need to define that ID within your Python code.

        Cheers,
        Andreas

        1 Reply Last reply Reply Quote 1
        • rsodreR
          rsodre
          last edited by

          I would like to call it by the actual plugin name name, like c4d.MyCommandData().
          I'll try to make some python shortcut functions that do that.

          Then what's CommandData::GetScriptName() useful for?

          1 Reply Last reply Reply Quote 0
          • a_blockA
            a_block
            last edited by

            Hi,

            you can ignore GetScriptName(), it is used internally to construct strings (or rather IDs) to refer to the online help for example.

            While it is not possible to call a command by name, you can for example scan the list of plugins for the name you are looking for, resulting in the ID you need to call the command.
            Roughly like so:

            plugins = c4d.plugins.FilterPluginList(c4d.PLUGINTYPE_COMMAND, True)
            for plugin in plugins:
                if plugin.GetName() == "My Plugin Name":
                        print plugin.GetFilename(), ": ", plugin.GetID()
            

            Cheers,
            Andreas

            1 Reply Last reply Reply Quote 1
            • a_blockA
              a_block
              last edited by

              Hi,

              just want to ask, if can consider this topic as solved.

              Bye,
              Andreas

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