ID 544734 - 3D data is not returned via Python when using it across a frame range and viewing the 2D Viewer

Follow

Problem summary
3D data is not returned via Python when using it across a frame range and viewing the 2D Viewer.
 
Customer reported version
Nuke 12.1v5
 
Customer reported platform
Windows 10
 
Steps to reproduce
 
1) Save the following code to a file named examples.py in your ~/.nuke folder: 

import nukeimport nukescripts.snap3ddef snapToPointsAnim( node=None, mode='t'):    '''    Animated versions of the three default snapping funtions in the axis menu    args:       node  -  node to snap       mode  -  which mode. Available modes are: 't' to match translation, 'tr', to match translation ans rotation, 'trs' to match translation, rotation and scale. default: 't'    '''    node = node or nuke.thisNode()    if mode not in ( 't', 'tr', 'trs' ):        # raise ValueError, 'mode must be "t", "tr" or "trs"'        print("mode wrong")        # KNOB MAP    knobs = dict( t=['translate'], tr=['translate', 'rotate'], trs=['translate', 'rotate','scaling'] )    # SNAP FUNCTION MAP    snapFn = dict( t=nukescripts.snap3d.translateToPoints,                   tr=nukescripts.snap3d.translateRotateToPoints,                   trs=nukescripts.snap3d.translateRotateScaleToPoints )    # SET REQUIRED KNOBS TO BE ANIMATED    for k in knobs[ mode ]:        node[ k ].clearAnimated()        node[ k ].setAnimated()        # GET FRAME RANGE    fRange = nuke.getInput( 'Frame Range', '%s-%s' % ( nuke.root().firstFrame(), nuke.root().lastFrame() ))    if not fRange:        return        # DO THE WORK    tmp = nuke.nodes.CurveTool() # HACK TO FORCE PROPER UPDATE. THIS SHOULD BE FIXED    for f in nuke.FrameRange( fRange ):        nuke.execute( tmp, f, f )        snapFn[ mode ](node)    nuke.delete( tmp ) # CLEAN UP THE HACKY BIT
 
This code is an example provided in the Nuke Python API Reference guide:
https://learn.foundry.com/nuke/developers/latest/pythondevguide/3D.html#extending-the-snap-menu 
 
2) Then save the following code to your ~/.nuke/menu.py file:
import examplesm = nuke.menu( 'Axis' )m.addCommand( 'Snap/Match selected position (animated)', lambda: examples.snapToPointsAnim( mode='t' ) )m.addCommand( 'Snap/Match selected position, orientation (animated)', lambda: examples.snapToPointsAnim( mode='tr' ) )m.addCommand( 'Snap/Match selected position, orientation, size (animated)', lambda: examples.snapToPointsAnim( mode='trs' ) )
 
3) Open Nuke.
 
4) Create a Cube node.
 
5) Animate the Cube node's Translate knobs over a number of frames.
 
6) In the Viewer, choose the vertex selection mode and select a number of vertices on the Cube.
 
7) Create a Card node.
 
8) Ensure you are viewing the 3D Viewer.
 
9) In the Card's Properties panel, select Match selected position (animated) from the snap_menu.
 

 
10) In the dialog that appears, enter a frame range and press OK.
 
11) Scrub through the frames in the Viewer and notice that the Card follows the Card:
 

 
12) Switch to the 2D Viewer.
 
13) In the Card's Properties panel, select Match selected position (animated) from the snap_menu again.
 
14) In the dialog that appears, enter a frame range and press OK.
 
15) Switch back to the 3D Viewer, to view the result, and scrub through the frames again.
 

 
Expected behaviour
3D data should be returned for all frames, regardless of whether you are viewing the 2D or 3D Viewer.
 
Actual behaviour
3D data is not returned via Python when using it across a frame range and viewing the 2D Viewer.
 
Workaround
Unknown.
 
Reproduced by support
This bug has been reproduced in:
Nuke 14.0v5 - Windows 10 - Linux CentOS 7
Nuke 10.0v1 - Windows 10 - Linux CentOS 7
 
Earliest version tested
Nuke 10.0v1
- This issue appears to be in all tested versions of the product
 

    We're sorry to hear that

    Please tell us why