Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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
    • Recent
    • Tags
    • Users
    • Login

    Threads and CallCommands

    Scheduled Pinned Locked Moved PYTHON Development
    5 Posts 0 Posters 482 Views
    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.
    • H Offline
      Helper
      last edited by

      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!

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        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".

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            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

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

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

              Thanks for the help Niklas.

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