Can I get the plugin(Command) help string in other C4DThread?
-
Hi everyone!
I saw in SDK documenation thatc4d.GetCommandHelp
can only be called in the main thread.
Is there a way to get help string in other threads? -
Hi gheyret, there is no real good workaround about, it GetCommandHelp is just an helper around a CoreMessage.
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. -
Thank you @m_adam , I will try it later today!
Cheers! -
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