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

    Can I get the plugin(Command) help string in other C4DThread?

    Cinema 4D SDK
    windows python 2024
    3
    4
    590
    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.
    • gheyretG
      gheyret
      last edited by

      Hi everyone!
      I saw in SDK documenation that c4d.GetCommandHelp can only be called in the main thread.
      Is there a way to get help string in other threads?

      www.boghma.com

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

        Hi gheyret, there is no real good workaround about, it GetCommandHelp is just an helper around a CoreMessage.
        image.png

        So technically speaking you can do this

        msg = c4d.BaseContainer(c4d.COREMSG_CINEMA_GETCOMMANDHELP)
        msg.SetInt32(c4d.COREMSG_CINEMA_GETCOMMANDHELP, 1034012)
            
        help = c4d.SendCoreMessage(c4d.COREMSG_CINEMA, msg, 0)
        print(help)
        

        While it will work, sending CoreMessage outside of the Main Thread can have side effect, and can mess-up some internal Message handling, so do it at your own risk.

        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        gheyretG 1 Reply Last reply Reply Quote 0
        • gheyretG
          gheyret @m_adam
          last edited by

          Thank you @m_adam , I will try it later today!
          Cheers!

          www.boghma.com

          1 Reply Last reply Reply Quote 0
          • ferdinandF
            ferdinand
            last edited by ferdinand

            Hey everyone,

            just to add a little disclaimer here, as Maxime gave a very hacking friendly answer with the a bit tame warning 'do it at your own risk'.

            What you are tyring to do is out of scope of support because it is a violation of the threading restrictions. The whole core message system is about events and UI, both things that are inherently bound to the main thread.

            Maxime's code just circumvents the main-thread check someone once put into our code for a reason, as that person also made sure to put a warning into the docs. When you are someone like Maxime, i.e., you know all the bits and bytes of Cinema 4D on a first-name basis, you can make a workaround like this work. But for everyone else I would strongly recommend not circumventing such things in production code. Just because a hack runs fine on a development machine, does not mean that a customer might not lose work due to a crash induced by such hack.

            The underlying issue we talked about this morning, is that in C++ one can easily defer things to the main thread with the aptly named ExecuteOnMaainThread while in Python one cannot. We are aware of this issue but it is quite costly to solve. An outcome of this thread, was that we at least promoted the priority of the already existing ticket for this issue in our task pool. We can however give no ETA when we will fix this, as doing this will cost quite some time.

            Cheers,
            Ferdinand

            MAXON SDK Specialist
            developers.maxon.net

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