Thread: Python access to multiple views

Reply to Thread
Results 1 to 8 of 8
  1. #1 Python access to multiple views 
    Join Date
    Aug 2010
    Posts
    4
    Im pretty new to python and nuke scripting and am trying to gain access to a read nodes 'file' knob, which I can do fine, but if there are multiple views setup (for stereo) im not sure how to get the different values, or tell if a knob is split.
    Cheers;
    Jordan
    Reply With Quote  

  2. #2  
    Join Date
    Jul 2009
    Posts
    36
    Read nodes don't have a 'views' knob like Write nodes, but nuke.views() will return a list of all available views in your script.
    So, for each view, you just have to replace %V by the name of the view and %v by the first letter of its name...
    Reply With Quote  

  3. #3  
    Join Date
    Aug 2010
    Posts
    4
    Cheers, i did know about the %v thing but what im after is a way to print what values are in 'file' property of the read node for the left and right views.
    Basically sometimes, for whatever reason, the file names get mixed up by the user. They will add a new version, but only in the right view while forgetting to update the left view (sometimes they use %v, sometimes they just load the file for both views). I wanted a way to acces the vale for both views to see if they are correct.
    In fact, id like to know how to access ANY knob that has different values per view.
    Reply With Quote  

  4. #4  
    Join Date
    Jul 2009
    Posts
    36
    I'm not sure I get it : there is only one value in the file property of a read node...
    If there are multiple views set in your script, this value is evaluated to different paths (one for each view) if it contains a %v or %V, otherwise the same path will be used for each view.

    If you want to load files from different locations (or with different names) for each view, you will need a read node for each one (and a joinviews node after that to tell Nuke which is which)
    Reply With Quote  

  5. #5  
    Join Date
    Jul 2009
    Posts
    36
    Quote Originally Posted by jordanw View Post
    In fact, id like to know how to access ANY knob that has different values per view.
    Just realized I didn't answer that...

    All knobs whose class inherits from the Array_Knob class can have different values for each view.
    For those, you can access the value for a specific view by using the 'view' parameter with the 'value' function (or the 'getValue' function).

    Example :
    Code:
    n = nuke.nodes.Blur()
    n['size'].splitView()
    n['size'].setValue(10, view='left')
    n['size'].setValue(20, view='right')
    print n['size'].value(view='left')   
    print n['size'].value(view='right')
    Reply With Quote  

  6. #6  
    Join Date
    Aug 2010
    Posts
    4
    Ahh, great. Thanks Kooki!! that was what i wanted to know!
    It also confirms what you said that the 'file' part of the read node dosent work that way.

    It seems that the way some of our nodes are working is like so:

    Code:
    set cut_paste_input [stack 0]
    version 6.0 v4
    Read {
     inputs 0
     file "\vdefault\vD:/Myfile_SR.%04d.dpx\vleft\vD:/Myfile_SL.%04d.dpx"
     last 78
     timecode 13:58:32:20
     name Read4
     selected true
     xpos -700
     ypos 8
    }
    This shows different values for left and right views when you change view and python's getValue only returns the current view value.
    Any ideas on this one?
    Reply With Quote  

  7. #7  
    Join Date
    Jul 2009
    Posts
    36
    With this node, you can get the whole value with the toScript() function
    Code:
    nuke.selectedNode()['file'].toScript()
    # Result: "\vdefault\vD:/Myfile_SR.%04d.dpx\vleft\vD:/Myfile_SL.%04d.dpx"
    Then you just have to split the string by '\v' to get a list [viewName, value, viewName, value]
    I've never seen this kind of notation before, but I'm guessing it is some sort of tcl expression...
    Reply With Quote  

  8. #8  
    Join Date
    Aug 2010
    Posts
    4
    ahhh, great! Thank you very much Kooki!
    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. cmiVFX Launches New Introduction to PYTHON Scripting Video
    By maynard in forum Programming & Development
    Replies: 3
    Last Post: October 13th, 2012, 04:05 AM
  2. VIP account - no response/no access
    By JudP in forum The Pad
    Replies: 13
    Last Post: August 11th, 2011, 12:22 AM
  3. Replies: 0
    Last Post: July 30th, 2010, 06:07 PM
  4. Nuke 5.1 v1 Released
    By shot_grable in forum NUKE from The Foundry
    Replies: 36
    Last Post: July 17th, 2010, 01:33 AM
  5. Multiple views - Different comps
    By Redsandro in forum Adobe After Effects
    Replies: 2
    Last Post: June 10th, 2008, 08:35 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