Aha, that works - thanks Ivan!

I'm sure I checked views >1, but maybe it was just doing "nuke.OutputContex(2)", oh well,

cam = nuke.nodes.Camera2()
cam['translate'].splitView()
cam['translate'].setValue((1,1,1), 0, "left")
cam['translate'].setValue((22,22,22), 0, "right")

ctx = nuke.OutputContext()
ctx.setView(1)
print cam['transform'].value(ctx)

ctx.setView(2)
print cam['transform'].value(ctx)

..does exactly what I need \o/

Ivan Busquets wrote:
Hi Ben,

Using an OutputContext to feed to ['transform'].value() should work.

To fill the OutputContext with the relevant view you'll need to use <outputcontext>.setView(view_index) instead of the name of the view directly.

Also, keep in mind that view 0 is always the "default" view, so if you have "left" and "right" views, they will be indices 1 and 2, not 0 and 1.

So, to get the camera transform matrix from the right view (assuming you have only left and right views), you should be able to do:


ctx = nuke.OutputContext()

ctx.setView(2)

camTransform = yourCameraNode['transform'].value(ctx)



Hope that helps.

Cheers,
Ivan


On Thu, Sep 1, 2011 at 3:45 AM, Ben Dickson <[email protected] <mailto:[email protected]>> wrote:

    I'm trying to get the two transform matrix's from a stereo camera,
    using the mycam['transform'].value() call, but I can't see anyway to
    do this..

    The value method doesn't take a view, only an OutputContext object,
    which seems to have no effect:

    cam = nuke.nodes.Camera2()
    cam['translate'].splitView()
    cam['translate'].setValue((1,__1,1), 0, "left")
    cam['translate'].setValue((22,__22,22), 0, "right")

    ctx_left = nuke.OutputContext("left")
    print cam['transform'].value(ctx___left)

    ctx_right = nuke.OutputContext("right")
    print cam['transform'].value(ctx___right)

    ..at least in 6.2v3 and 6.3v1 that returns the matrix for whatever
    the current view is. Also tried "ctx = nuke.OutputContext();
    ctx.setView(0)" etc, same thing

    I also tried:

    for view in nuke.views():
       nuke.activeViewer().setView(__view)
       print "current view:", nuke.activeViewer().view()
       print cam['transform'].value()

    ..which prints out the view, but still returns the same matrix

    ...and:

    ct = nuke.nodes.CurveTool()

    for view in nuke.views():
       nuke.activeViewer().setView(__view)
       nuke.execute(ct, nuke.frame(), nuke.frame())
       print cam['transform'].value()


    Any ideas? While I could manually create the matrix, that's a bit
    tedious, especially given if there are any axis's parented.. Plus,
    I'd also have to modify the nukescripts.snap3d methods I'm using
    (which also don't take a view, although they use getValue etc which do)
-- ben dickson
    2D TD | [email protected] <mailto:[email protected]>
    rising sun pictures | www.rsp.com.au <http://www.rsp.com.au>
    _________________________________________________
    Nuke-python mailing list
    Nuke-python@support.__thefoundry.co.uk
    <mailto:[email protected]>,
    http://forums.thefoundry.co.__uk/ <http://forums.thefoundry.co.uk/>
    http://support.thefoundry.co.__uk/cgi-bin/mailman/listinfo/__nuke-python
    <http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python>



------------------------------------------------------------------------

_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

--
ben dickson
2D TD | [email protected]
rising sun pictures | www.rsp.com.au
_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to