Fantastic. Thanks so much Gabor. You’ve saved me twice now:)
Michael > On Feb 8, 2017, at 4:23 AM, Gabor L. Toth <glt...@gmail.com> wrote: > > Hi! > > Welcome! :) Here is the latest version of my script, it should work with > expressions, we also use that often. It is used just selecting the readnodes > and executing the script. We use it many times so it is tied to a hotkey, I > think this is better than having buttons on each node. > > Hope it helps > Gabor > > > On Wed, Feb 8, 2017 at 2:35 AM, Michael Hodges <mhod...@morganfalls.com > <mailto:mhod...@morganfalls.com>> wrote: > > I’ve begun to answer my own question and I think I’m pretty close on this. > > I’ve started to adapt a script I found from Gabor Toth (thanks Gabor!) and > hopefully this will help others as well. > > I put a python button on the read node that contains the script below which > replaces the frame ranges correctly. > > The reason I used a button is that it was an easy way to see if it would > work, and two, I couldn’t really figure out how to configure the command to > the specific node on demand. > > > > Three questions: > > 1. Is a button the a good way to achieve this? I thought it might be best > to have it hardwired on the node as it will be buried in one or more gizmos > (that may be created procedurally) and I didn’t trust my Python chops to > isolate it from the other read nodes in the script > > > 2. Assuming that this is the best approach how would I activate the button > press from another node? > > > 3. Since the “file” value is generated by an expression ( in my case: [value > Controller.ClipPath] the real path isn’t being resolved to the script and > fails. It does work as expected with a text path. Would a different > expression technique work or do I have to create some additional python magic? > > > > Thanks! > > > Michael > > > > ################ > > import nuke > import os > import os.path > import math > import glob > import re > > n = nuke.thisNode() > > > seqPath = n.knob('file').value() > if seqPath is not None and re.match('.*\.%0.*', seqPath): > indx = seqPath.find('%0') > pattern = '%0' + seqPath[indx + 2] + 'd' > seqPathMask = seqPath.replace(pattern, '*') > print '' > print 'PathMask: %s' % (seqPathMask) > seqDir = os.path.dirname(seqPath) > print 'Directory: %s' % (seqDir) > if os.path.exists(seqDir): > files = os.listdir(seqDir) > #print files > > #sorting files > filteredFiles = glob.glob(seqPathMask) > filteredFiles.sort() > if len(filteredFiles) != 0: > (firstFileName, ext) = > os.path.splitext(filteredFiles[0]) > firstFileTags = firstFileName.split('.') > > sfs = firstFileTags[-1] > print 'Extension: ' + ext > sf = int (sfs) # converted to int > print "Start frame: %s" % (sf) > > (lastFileName, ext) = > os.path.splitext(filteredFiles[len(filteredFiles)-1]) > lastFileTags = lastFileName.split('.') > efs = lastFileTags[-1] > ef = int (efs) > print "End frame: %s" % (ef) > > n.knob('first').setValue(sf) > n.knob('last').setValue(ef) > else: > print 'No matching files in this directory! > Skipping...' > else: > print 'Warning! Directory doesnt exist: ' + seqDir > else: > pass > > > > > > > On Feb 7, 2017, at 11:16 AM, Michael Hodges <mhod...@morganfalls.com > > <mailto:mhod...@morganfalls.com>> wrote: > > > > Is there a way to detect/update the frame range of an image sequence ( > > Example_File.#####.dpx) in a read node? > > > > I’ve got some expressions that can change the input file within a gizmo > > read node but then I’m stuck with the previous file’s values. I understand > > that this may be end up having to be a some sort of python file-counting > > callback but I want to check first if there is a way of doing it within > > Nuke. > > > > > > Thanks, > > > > Michael_______________________________________________ > > Nuke-users mailing list > > Nuke-users@support.thefoundry.co.uk > > <mailto:Nuke-users@support.thefoundry.co.uk>, > > http://forums.thefoundry.co.uk/ <http://forums.thefoundry.co.uk/> > > http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users > > <http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users> > > _______________________________________________ > Nuke-users mailing list > Nuke-users@support.thefoundry.co.uk > <mailto:Nuke-users@support.thefoundry.co.uk>, http://forums.thefoundry.co.uk/ > <http://forums.thefoundry.co.uk/> > http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users > <http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users> > > <glt_reloadRange.py>_______________________________________________ > Nuke-users mailing list > Nuke-users@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ > http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
_______________________________________________ Nuke-users mailing list Nuke-users@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users