Rich – yeah, that’s pretty much in line with what I was getting at.

-Nathan



From: Richard Bobo 
Sent: Friday, April 25, 2014 10:31 AM
To: Nuke Python discussion 
Subject: Re: [Nuke-python] Execute Write from Python panel

Simon,

OK, based on Nathan’s suggestions and a little help from our in-house 
programmer, I have a working version: 

http://pastebin.com/Siy8VEV8

There are two classes now — one for the Write node Selection/Render panel and 
one for the threaded nuke.execute command.

In the knobChanged method, when you press the render button, the renderWrites 
class in initialized and started -- with an argument of the name of the 
currently selected Write node from the drop down menu. That is passed to the 
renderWrites class and provided as the argument to the nuke.execute function 
inside executeInMainThread.

Nathan — Is this pretty much what you meant…?


Rich


Rich Bobo
Senior VFX Compositor
Armstrong White
Email:  rich.b...@armstrong-white.com
http://armstrong-white.com/

Email:  richb...@mac.com
Mobile:  (248) 840-2665
Web:  http://richbobo.com/

“Many of the great achievements of the world were accomplished by tired and 
discouraged men who kept on working.”
- Unknown

On Apr 25, 2014, at 7:17 AM, Simon Björk <bjork.si...@gmail.com> wrote:


  Thanks all for your replys. 

  I must admit, I'm having a hard time to grasp the solutions. Python panels 
are a black hole for me. Just today I ran into this issue once again when 
trying to add new trackers to a tracker node (node["tracks"].execute()).

  Nathan, do you know of any example scripts that uses your suggestions?

  Cheers,
  Simon




  2014-04-24 22:51 GMT+02:00 Richard Bobo <richb...@mac.com>:

    Thanks, Nathan.


    On Apr 24, 2014, at 3:49 PM, Nathan Rusch <nathan_ru...@hotmail.com> wrote:


      A few things if you’re going to use threads:

      - I would recommend using `threading` instead of `thread`, as it’s more 
approachable, and joining your thread if you want to block until the render is 
done.

    I started by using threading, but then found a different example that used 
thread, so I went down that road, instead. I’ll read up on the differences...



              t = threading.Thread(target=self.renderWrites)
              t.start()
              t.join()

      - You may want to consider moving the thread target function off of your 
dialog class, and just passing the Write node(s) to it via the Thread object. 

    I was wondering about that - if it was a good idea to combine the two or 
not…


      - There’s no reason to use `nuke.executeInMainThreadWithResult` unless 
you actually need to get a return value.

    When I was getting nothing at all to work, I wondered if there was some 
result that I needed to wait for (just poking around in the dark), so that’s 
why I switched it. Then, when things actually started to work better, I never 
switched it back…


      - You need to pass the function and write node through 
`nuke.executeInMainThread` separately. Otherwise, you’re just calling 
`nuke.execute(writeNode)` and passing the result of that (which is probably 
None) to `nuke.executeInMainThread`.

              nuke.executeInMainThread(nuke.execute, args=(writeNode,), 
kwargs={'continueOnError':True})

    I’ll have to let that settle into my brain for a bit. Still partly cloudy 
on a lot of how this is supposed to work…



      - A more idiomatic way to handle exceptions:

              try:
                  # Something
              except Exception as e:
                  print 'ERROR: %s' % e  # Or whatever you want to do



    I did have…
    except (TypeError, RuntimeError) as e:
    print “ERROR:”, e

    But, wondered if I could get more info by trying to catch anything and 
everything… It didn’t help me diagnose anything better, though.



      Hope this helps.

    Yes, I’m sure it will, once I can digest it and try out some more examples.

    Thanks!
    Rich




      -Nathan

      From: Richard Bobo 
      Sent: Thursday, April 24, 2014 12:22 PM
      To: Nuke Python discussion 
      Subject: Re: [Nuke-python] Execute Write from Python panel

      Simon,

      Since I’ve never tried to do coding for a separate thread, I thought I’d 
give it a try:

      http://pastebin.com/niEV5FPF

      My version has some of the very same elements as Mitja’s does. And, my 
code works -- *most* of the time...

      ...However, sometimes it gets a...
      "TypeError: expected callable object, NoneType found”
      ...and sometimes it gets a…
      “TypeError: ‘NoneType’ object is unscriptable”
      ...and sometimes it gets a…
      “RunTimeError: Cancelled”

      So, not too reliable!!   (8^P

      If my co-worker Python-guru-friend was here today, I’m sure he could help 
me debug the problem. Perhaps someone else here could help…?

      So close, yet, so far...

      Rich 


      Rich Bobo
      Senior VFX Compositor
      Armstrong White
      Email:  rich.b...@armstrong-white.com
      http://armstrong-white.com/

      Email:  richb...@mac.com
      Mobile:  (248) 840-2665
      Web:  http://richbobo.com/

      "What you can do, or dream you can do, begin it; boldness has genius, 
power and magic in it."
      - Johann von Goethe






      On Apr 24, 2014, at 3:08 AM, Simon Björk <bjork.si...@gmail.com> wrote:

      Hi Mitja, 

      thanks for the reply. I tested you code, but unfortunately I still get 
the "I'm already executing something else" error. Does it work for you?

      Best regards,
      Simon



      2014-04-24 8:19 GMT+02:00 Mtja Müller-Jend <filmk...@gmx.de>:

      Hi Simon,

      try to use threading to execute the node: http://pastebin.com/06azNCzx

      Cheerz,

      Mitja

      Am 4/23/2014 11:54 PM, schrieb Simon Björk:

      I'm trying to execute a Write node from a Python panel, but I'm not 
having any luck. As I try to exectute the render I get a RuntimeError: I'm 
already executing something else.


      One solution would be to use a Nuke panel instead, but I would really 
need a Python panel for this script. See short example script here: 
http://pastebin.com/NzStQNhk.

      I would really appriciate some help on this.

      Best regards,
      Simon

       

_______________________________________________
Nuke-python mailing list
Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python



      _______________________________________________
      Nuke-python mailing list
      Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
      http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python



      _______________________________________________
      Nuke-python mailing list
      Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
      http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python




--------------------------------------------------------------------------
      _______________________________________________
      Nuke-python mailing list
      Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
      http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

      _______________________________________________
      Nuke-python mailing list
      Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
      http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python



    _______________________________________________
    Nuke-python mailing list
    Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
    http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python



  _______________________________________________
  Nuke-python mailing list
  Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
  http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python




--------------------------------------------------------------------------------
_______________________________________________
Nuke-python mailing list
Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
_______________________________________________
Nuke-python mailing list
Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to