Thread: .py script works in Script Editor, but not from menu

Reply to Thread
Results 1 to 4 of 4
  1. #1 .py script works in Script Editor, but not from menu 
    I have a little python script I wrote and it works fine when I run it from the Script Editor window inside Nuke. I saved it out as a .py and added it to my menu in the menu.py

    If I run it from the menu it will only work the first time, every time after that i get syntax errors.

    For example - RuntimeError: Syntax error at "'red'" referring to this line -

    s1 = nuke.nodes.Shuffle()
    s1['red'].setValue('red')

    Anyone know what's up with this?
    Reply With Quote  

  2. #2  
    Join Date
    Aug 2006
    Location
    India
    Posts
    246
    import nuke
    def somthing():
    s1 = nuke.nodes.Shuffle()
    s1['red'].setValue('red')
    if s1 is == True:
    print ok
    else:
    return

    You have to define your script for execute to run from menu.py. Change something to as per your wish.

    import something add this line into your menu.py.
    Failure is not an option.. But failure has to be an option...
    ____________________
    My Nuke Tutorial page
    Reply With Quote  

  3. #3  
    OK, I added a def something(): at the top and a something() at the bottom. And it worked again the first time only. Every time after that I get a syntax error at "red"
    Reply With Quote  

  4. #4  
    Join Date
    Aug 2006
    Location
    India
    Posts
    246
    Try like this...

    import nuke
    def shuffleRedOnly():
    s1 = nuke.createNode('Shuffle')
    s1['red'].setValue('red')
    s1['green'].setValue('red')
    s1['blue'].setValue('red')
    s1['alpha'].setValue('red')

    n = nuke.toolbar('Nodes')
    n.addCommand('Test/shuffleRedOnly', 'shuffleRedOnly.shuffleRedOnly()')
    Failure is not an option.. But failure has to be an option...
    ____________________
    My Nuke Tutorial page
    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. python script as part of the menu
    By Lukasz Omasta in forum NUKE from The Foundry
    Replies: 2
    Last Post: August 20th, 2010, 11:45 AM
  2. personal menu for opening script templates
    By arikitraun in forum Nuke Plugins & Scripts
    Replies: 9
    Last Post: March 18th, 2010, 06:53 PM
  3. TCL for Script Editor
    By topbrick in forum NUKE from The Foundry
    Replies: 9
    Last Post: April 8th, 2009, 11:20 AM
  4. Script Editor feedback...?
    By chunkified in forum NUKE from The Foundry
    Replies: 8
    Last Post: February 2nd, 2009, 02:07 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