It's very weird indeed. I believe what's happening is that valueAt() is already returning all the values in the matrix as a list, even if you don't give it an index number.
See the difference between doing: node['world_matrix'].value() and node['world_matrix'].valueAt(7) # This one returns a list with all the matrix values, but reversed :S You could do something like: for i in range(0,16): m[i] =node['world_matrix'].valueAt(7)[i] And then transpose the matrix (because of the list coming out in reverse order): m.transpose() Or just reverse the list as a previous step: matrix_list = node['world_matrix'].valueAt(7) matrix_list.reverse() for i in range(0,16): m[i] = matrix_list[i] Still, the fact that value() and valueAt() provide different outputs is very confusing, and should definitely be reported, I think. On Sun, Mar 13, 2011 at 3:13 PM, Frank Rueter <[email protected]> wrote: > has anyone tried the valueAt() method to get a matrix at a given frame? > > It seems to return a different array than using value() and making sure the > current frame in the root is the one you're after. > > in my scenario (camera with "frame" expression in translate.x): > > for i in range(0,16): > m[i] = node['world_matrix'].value( i%4, i/4) > print '\n%s'%m > > returns this on frame 7: > {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 7, 0, 0, 1} > > > while this: > > for i in range(0,16): > m[i] = node['world_matrix'].valueAt( 7, i%4, i/4) > print '\n%s'%m > > > returns: > {1, 0, 0, 7, 1, 0, 0, 7, 1, 0, 0, 7, 1, 0, 0, 7} > > > > I guess I will have to manually step through frames for this?! > > Cheers, > frank > > > > On Mar 9, 2011, at 2:53 PM, Frank Rueter wrote: > > thanks for the confirmation. I'm looping through the fields manually for > now which seems to work > > On Mar 9, 2011, at 2:16 PM, Ivan Busquets wrote: > > Yeah, I've found this to be flaky too, or at least not consistent with > other knobs. > > As pixelcowboy was saying, the value() method of that matrix knob expects 2 > indices (1 for the row, one for the column). > But you're right, Frank, I think this should return a list with all values > when no index is given, just like what you get from valueAt(). > > Also, toScript() doesn't seem to work correctly on them either (returns all > 0s) > > As for setting the values, I've always resorted to iterating through them. > :( > > Bug report? > > > > On Tue, Mar 8, 2011 at 4:59 PM, [email protected] < > [email protected]> wrote: > >> cam['world_matrix'].array() >> Works fine on the color matrix node, but doesn't seem to be doing the >> right thing on the camera matrix knobs... >> >> >> On Tue, Mar 8, 2011 at 4:54 PM, [email protected] >> <[email protected]> wrote: >> > I think you need to give it an index: >> > print cam['world_matrix'].value(0,0) >> > >> > On Tue, Mar 8, 2011 at 4:45 PM, Frank Rueter <[email protected]> >> wrote: >> >> matrix knobs seem o behave in mysterious ways: >> >> >> >> this will give me a single float value: >> >> cam = nuke.toNode('Camera4') >> >> print cam['world_matrix'].value() >> >> >> >> >> >> while this will give me all 16 values: >> >> print cam['world_matrix'].valueAt(300) >> >> >> >> Also, this only assigns the first four values, not the whole thing: >> >> >> >> cam = nuke.toNode('Camera4') >> >> newCam = nuke.toNode('Camera1') >> >> newCam['useMatrix'].setValue( True ) >> >> newCam['matrix'].setValue( cam['world_matrix'].valueAt(300) ) >> >> >> >> >> >> Do I really have to manually iterate over the values to assign them or >> has someone found a nicer way of doing this? >> >> >> >> Cheers, >> >> frank_______________________________________________ >> >> Nuke-python mailing list >> >> [email protected] >> >> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python >> >> >> > >> _______________________________________________ >> Nuke-python mailing list >> [email protected] >> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python >> > > _______________________________________________ > Nuke-python mailing list > [email protected] > http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python > > > _______________________________________________ > Nuke-python mailing list > [email protected] > http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python > > > > _______________________________________________ > Nuke-python mailing list > [email protected] > http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python > >
_______________________________________________ Nuke-python mailing list [email protected] http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
