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]> 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]
> rising sun pictures | www.rsp.com.au
> ______________________________**_________________
> Nuke-python mailing list
> Nuke-python@support.**thefoundry.co.uk<[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

Reply via email to