Thanks, Nathan! I already have a good 4-line gizmo finder, obviously is one is a little bigger... I think it would have taken me a while to figure this out ( if ever), so much appreciated.
On Thursday, February 27, 2014, Nathan Rusch <[email protected]> wrote: > Filtering out Nuke's distributed plugins is pretty simple: > > import os > > nukeDir = os.path.dirname(nuke.env['ExecutablePath']) > externalPlugins = [p for p in nuke.plugins() if not p.startswith(nukeDir)] > # Trim paths and/or filter extensions as needed > > > To find all of the external gizmos being used in your script is also > simple (given `nukeDir` from above): > > # This is basic. In reality, you want to recurse into Groups > externalGizmos = [n for n in nuke.allNodes() if isinstance(n, nuke.Gizmo) > and not n.filename().startswith(nukeDir)] > > > Finding external plugins that are actively being used in your script (as > opposed to just loaded by Nuke) is trickier, especially if you need to > account for custom Reader/Writer classes, but you can get close pretty > easily (again, given `nukeDir`): > > # Non-gizmo plugins only > externalPlugins = [p for p in nuke.plugins(0, '*.ofx', '*.%s' % > nuke.PLUGIN_EXT) if not p.startswith(nukeDir)] > > > It's obviously easy to combine this with the gizmo query to get a more > complete cross-section. To filter it even further, you could try to take > the results of this call and intersect the plugin class basenames with the > classes of all nodes in your script (using special cases for OFX plugins), > and then add some more specialized crawling to track down any nodes that > might be actively using Reader/Writer plugins. > > Hope this helps. > > > -Nathan > > > *From:* Erwan Leroy<javascript:_e(%7B%7D,'cvml','[email protected]');> > *Sent:* Thursday, February 27, 2014 11:38 AM > *To:* Nuke Python > discussion<javascript:_e(%7B%7D,'cvml','[email protected]');> > *Subject:* Re: [Nuke-python] Finding plugins > > Here is a fragment of a code I used a while ago. It was only checking > gizmos, and was reading the info inside gizmo files that you may not need, > but it might give you an idea to adapt to your problem: > > import re > def gizmoCheck(): > gizmos = nuke.plugins(0, '*.gizmo') > > for gizmoPath in gizmos: > gizmoLoaded = False > gizmoFile = open(gizmoPath, 'r') > gizmoTxt = ''.join(gizmoFile) > gizmoFile.close() > gizmoName = re.split('[\\\/]', gizmoPath)[-1] > gizmoName = re.sub('\.gizmo', '', gizmoName) > print 'Checking '+gizmoName > for node in nuke.allNodes(): > if node.Class() == gizmoName: > gizmoLoaded = True > ..... > > There might be a much better way to do this, I'm still just messing with > code until I get my stuff to work. > > > On Thu, Feb 27, 2014 at 11:21 AM, Den Serras > <[email protected]<javascript:_e(%7B%7D,'cvml','[email protected]');> > > wrote: > >> Anyone have a good trick for getting a list of all non-Nuke standard >> plugins used in a comp? Having trouble getting nuke.plugins to work without >> weird errors. >> >> Thanks! >> Den >> >> _______________________________________________ >> Nuke-python mailing list >> [email protected]<javascript:_e(%7B%7D,'cvml','[email protected]');>, >> http://forums.thefoundry.co.uk/ >> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python >> >> > > ------------------------------ > _______________________________________________ > Nuke-python mailing list > [email protected]<javascript:_e(%7B%7D,'cvml','[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
