Thread: Python, creating Write node with file parameter

Reply to Thread
Results 1 to 10 of 10
  1. #1 Python, creating Write node with file parameter 
    Join Date
    Oct 2008
    Location
    Stuttgart, Germany
    Posts
    109
    Hi,

    i would like to create a write node with python and assign the string for the "file" knob at the same time.
    Code:
    nuke.nodes.Write()
    just creates an empty write node. How would you go about putting the file destination into the file knob at the same time?

    Thanks
    Reply With Quote  

  2. #2  
    Join Date
    Sep 2004
    Posts
    1,202
    nuke.createNode('Write', ' file the_Path/to_your/file.here')

    or

    w = nuke.createNode('Write')
    w['file'].setValue('the_Path/to_your/file.here')

    Among many other ways.
    dg | ••• | imdb
    Reply With Quote  

  3. #3  
    Join Date
    Oct 2008
    Location
    Stuttgart, Germany
    Posts
    109
    Thanks alot Diogo!
    Reply With Quote  

  4. #4  
    Join Date
    Oct 2008
    Location
    Stuttgart, Germany
    Posts
    109
    I got a problem understanding the way Python handles the statement

    Code:
    w = nuke.createNode('Write')
    If you just enter this code, Nuke already creates a write Node. I thought by using this statement, you would simply assign the create command to the variable w. Instead, the command is also executed. How can i stop Nuke from creating the write node, i only want to assign the command to w and then later in the script, i want to execute it by calling w.
    Reply With Quote  

  5. #5  
    Join Date
    Jun 2009
    Posts
    7
    Python "calls it as it sees it".
    nuke.createNode('Write') creates a write node and returns the object it just created (a write object at some memory address). By interpreting w = nuke.createNode("Write"), you're not saying "assign w to the command nuke.createNode('Write')", you're saying "Create a node and assign w to that object just created"

    But again, python "calls it as it sees it". If you want to only interpret the command under certain conditions (as you appear to do), put it in an if statement.
    Reply With Quote  

  6. #6  
    Join Date
    Sep 2004
    Posts
    1,202
    VFXEctropy already explained the bit regarding the variable assignment, as he told you are not assigning w to the command it self, but to what that command returns.

    If for any reason you need to evaluate a command later on, you can so something like this:

    w = 'nuke.createNode( "Write", inpanel=False )'
    eval( w )

    This way the w var is assigned to a string 'nuke.createNode("Write", inpanel=False)', so it won't run anything until you evaluate that string by doing eval( w ).
    dg | ••• | imdb
    Reply With Quote  

  7. #7  
    Join Date
    Oct 2008
    Location
    Stuttgart, Germany
    Posts
    109
    Thanks alot guys for explaining that to me. That could come in handy
    Reply With Quote  

  8. #8  
    Join Date
    Sep 2008
    Posts
    114
    sorry for hijacking this thread.. what does the "inpanel = False" argument do?

    i just noticed i need it if i want a read node to evaluate the informations from a .MOV file.

    cheers & thanks

    alex
    Reply With Quote  

  9. #9  
    Join Date
    Oct 2008
    Location
    Stuttgart, Germany
    Posts
    109
    It means the properties panel wont be opened when that node is created. Why that should be relevant with your .mov file though i dont know...
    Reply With Quote  

  10. #10  
    Join Date
    Sep 2008
    Posts
    114
    ahh good info. thanks.

    makes completely no sense, why i need it though, but good to know for my other scripts

    cheers

    alex
    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 linking curves in text node
    By Furnace in forum NUKE from The Foundry
    Replies: 7
    Last Post: March 19th, 2009, 06:48 PM
  3. Write node filename error
    By xenial in forum NUKE from The Foundry
    Replies: 9
    Last Post: December 20th, 2008, 01:27 PM
  4. Add Channel in Shuffel Node with python
    By idioteque in forum NUKE from The Foundry
    Replies: 1
    Last Post: November 21st, 2008, 08:16 AM
  5. Adding parameter expression in TEXT Node
    By mclemens in forum NUKE from The Foundry
    Replies: 1
    Last Post: September 19th, 2008, 04:59 AM
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