Thread: personal menu for opening script templates

Reply to Thread
Results 1 to 10 of 10
  1. #1 personal menu for opening script templates 
    Join Date
    Feb 2009
    Posts
    19
    Hi!
    I have several .nk files that I want to use as templates.
    I want to make a python script with my own list menu with a button for every template, so when I push on the desired button a new nuke opens with the selected template.
    What's the best way for doing it into nuke?

    Thank you very much!
    Reply With Quote  

  2. #2  
    Join Date
    Feb 2009
    Posts
    19
    Ok,
    I think I've found a solution that opens a nuke script from an already opened nuke window:

    import subprocess
    subprocess.Popen([<nukeExecutablePath>, <filePath>], shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
    Reply With Quote  

  3. #3  
    Join Date
    Feb 2007
    Posts
    993
    subprocess.call is a lighter (and cleaner) way to call another program if you need to be returning output codes from it.
    Last edited by alkali; March 17th, 2010 at 11:46 AM.
    Reply With Quote  

  4. #4  
    Join Date
    Feb 2009
    Posts
    19
    I'll try with this method,
    Thank you very much alkali!
    Reply With Quote  

  5. #5  
    Join Date
    Feb 2007
    Posts
    993
    Just to clarify, you're intentionally trying to open these templates in a new Nuke process instance, correct? As opposed to opening the templates in a new workspace under the currently running Nuke process?
    Reply With Quote  

  6. #6  
    Join Date
    Feb 2009
    Posts
    19
    Yes, initially I was thinking on a new nuke process instance, but don't know if the other option will be better...
    Last edited by arikitraun; March 17th, 2010 at 01:32 PM.
    Reply With Quote  

  7. #7  
    Join Date
    Feb 2007
    Posts
    993
    My first thought is it would be better to keep things sandboxed in the same Nuke process to avoid having two different instances fighting for RAM (if your comps get heavy). This would also make it much easier to set up the menu item. However, separating the comps into different instances would keep the others alive if one decided to crash, so there are tradeoffs.
    Reply With Quote  

  8. #8  
    Join Date
    Feb 2009
    Posts
    19
    Then I preffer the choice of individual instances, I need to manage the closing individually.
    ...so should I keep on using "subprocess.Popen()" then?

    Thanks!
    Reply With Quote  

  9. #9  
    Join Date
    Aug 2007
    Location
    Erding / Munich
    Posts
    54
    I am sure nuke is already able to do that.

    When I remember correctly there is nuke.scriptOpen(filename) to open the script in a new instance and nuke.scriptAdd(filename) to load it into the current script. No need to do system calls.

    You can easily look this up in the python reference. Also nuke's init.py and menu.py are a great source to look for things like this. You could for example look what the menu File -> Open Script is calling as it is exactly doing what you are looking for except that there is a fileselect dialog to select the script to open.
    Digital Artist : Compositor / TD - nuke | shake | after effects - tinitron.de
    Reply With Quote  

  10. #10  
    Join Date
    Feb 2009
    Posts
    19
    Thank you very much tinitron!
    I think nuke.scriptOpen(filename) is just what I was looking for, with transparency of creating processes or intances.
    Reply With Quote  

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Nuke 5.1 v1 Released
    By shot_grable in forum NUKE from The Foundry
    Replies: 36
    Last Post: July 17th, 2010, 01:33 AM
  2. Python, adding icon to new toolbar sub menu?
    By mattdleonard in forum NUKE from The Foundry
    Replies: 2
    Last Post: March 6th, 2010, 04:42 PM
  3. Refrencing a Script within a script
    By Dotcommer in forum NUKE from The Foundry
    Replies: 6
    Last Post: November 17th, 2009, 06:47 PM
  4. Making use of Menu Objects?
    By suredosan in forum Nuke Plugins & Scripts
    Replies: 0
    Last Post: January 26th, 2009, 07:02 PM
  5. Run Script from Menu in Nuke 5
    By im.thatoneguy in forum NUKE from The Foundry
    Replies: 4
    Last Post: May 19th, 2008, 07:25 PM
Bookmarks
Bookmarks
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts