Doesn't seem to be any easy way,

* nuke.sample doesn't take a view index (like most of the knobs), nor
OutputContext (like the knob's evaluate method)

* nuke.sample(..., "green.left", ...) doesn't work as I half-hoped

* Creating a temporary CurveTool doesn't work properly on a stereo image
(only creates one value, from the current view)

..but if you OneView before the CurveTool, it'll work:


def getpixel(node, x, y, viewname):
    assert viewname in nuke.views()

    # Get specified view
    ov = nuke.nodes.OneView(inputs = [node])
    ov['view'].setValue(viewname)

    # Make CurveTool..
    ct = nuke.nodes.CurveTool(inputs = [ov])
    ct['operation'].setValue('Avg Intensities')

    # ..for a one-pixel region
    ct['ROI'].setValue(x, 0) # x
    ct['ROI'].setValue(y, 1) # y
    ct['ROI'].setValue(x+1, 2) # r
    ct['ROI'].setValue(y+1, 3) # t

    # Execute the CurveTool
    nuke.execute(ct, nuke.frame(), nuke.frame())

    # Get the RGB value
    val = ct['intensitydata'].value()

    # Clean up
    nuke.delete(ct)
    nuke.delete(ov)

    return val


print getpixel(nuke.selectedNode(), 512, 512, 'left')


On 02/11/13 02:38, Steve Newbold wrote:
> Hi,
> 
> What's the most straight forward way of sampling (node.sample()) a
> specific view.  I can sample the view currently selected in the viewer
> but can't see an obvious way to choose which view I wish to sample. 
> Must be something straight forward?
> 
> Cheers,
> Steve
> _______________________________________________
> 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

-- 
ben dickson
2D TD | ben.dick...@rsp.com.au
rising sun pictures | www.rsp.com.au
_______________________________________________
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