Threads and CallCommands

On 22/05/2014 at 11:36, xxxxxxxx wrote:

Is it possible to use a c4d.CallCommand() In A thread?

Here is a small snipet of my code:

import c4d,time
from c4d import gui
import socket
  
class RB_Client(c4d.threading.C4DThread) :
    global Cthread
    def Main(self) :
        print "Before"
        c4d.CallCommand(12099) # Render to Picture Viewer
        print "After"
        
global Cthread
Cthread = RB_Client()
Cthread.Start()

This should send the current scene to render in the picture viewer, instead it is ignored/nothing happens. Any help on this would be great!

On 22/05/2014 at 14:40, xxxxxxxx wrote:

No, it is not. The command would be executed in that other thread, too. Command plugins are 
meant to be executed in the main thread.

Take a look at "Call function from main thread".

On 27/05/2014 at 14:11, xxxxxxxx wrote:

Would you happen to know if there are any example plugins that use the c4d.SpecialEventAdd()? Or if there is an alternate way to tell Cinema to start rendering from within a thread?

Thanks.

On 28/05/2014 at 01:43, xxxxxxxx wrote:

I don't know of examples that do, but you'll get the ID you pass to SpecialEventAdd() 
passed to the CoreMessage() method of a GeDialog or MessageData plugin.

I would've told you if there is. 😉

Btw, here's how I do it in the PV Render Queue plugin. I use the GeDialog.Timer()
method to check if the renderer is still running, and if it is not, start a new rendering.
No thread needed therefore.

    def Timer(self, msg) :
        rendering = c4d.CheckIsRunning(c4d.CHECKISRUNNING_EXTERNALRENDERING)
        if self.active_queue and not rendering:
            file\_ = None
            for file\_ in self.files:
                if not file\_.done: break
            if file\_ and not file\_.done:
                self.RenderFile(file\_)
                self.tree.Refresh()
            else:
                self.active_queue = False
                self.UpdateUI()
            c4d.EventAdd()

-Niklas

On 28/05/2014 at 06:59, xxxxxxxx wrote:

Thanks for the help Niklas.