Only issue with the fromUserText approach is you need to know the frame range 
in advance.

If you need to figure the range out yourself on the fly, something like the 
code below will work. Note that it is written to be extra careful about the 
possibility of other files existing in the same directory as the sequence in 
question, even files with identical names but different extensions.


# 'newPath' is the new path you want to assign to the Read’s file knob
# 'node' is the Read node

import glob
import os
import re

import nukescripts

cleanPath = nukescripts.replaceHashes(newPath)
padRE = re.compile('%0(\d+)d')
padMatch = padRE.search(cleanPath)

if padMatch:
    padSize = int(padMatch.group(1))
    frameList = sorted(glob.iglob(padRE.sub('[0-9]' * padSize, cleanPath)))
    first = os.path.splitext(frameList[0])[0][-padSize:]
    last = os.path.splitext(frameList[-1])[0][-padSize:]
    node['file'].fromUserText('%s %s-%s' % (cleanPath, first, last))


-Nathan



From: Ivan Busquets 
Sent: Tuesday, January 03, 2012 2:20 PM
To: Nuke Python discussion 
Subject: Re: [Nuke-python] How to update Read-Node frame ranges

Hi Vincent, 

Use the .fromUserText() method to change the "file" knob, instead of .setValue()

This will trigger the same callbacks that are triggered when you change the 
file manually, including setting the framerange and format knobs.




On Tue, Jan 3, 2012 at 2:16 PM, Vincent Langer <[email protected]> 
wrote:

  hi there,

  i have a little script which changes the filepath of all the readnodes. 
(update 3d renderpasses)

  workes fine - but how can i update the readnode frameranges if these have 
changed?
  how can i get the first and last framenumber of a given sequence?

  hope anyone can help

  cheers,
  vincent



  ----------------------------------------------------------------
  This message was sent using IMP, the Internet Messaging Program.

  _______________________________________________
  Nuke-python mailing list
  [email protected], http://forums.thefoundry.co.uk/
  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
_______________________________________________
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