SearchReplacePanel v1.3
This location is for Registered Users Only.
Perhaps you need to login or register.
Contributor: Frank Rueter
a better search and replace panel
Requirements:
13.1, 12.2, 12.1, 12.0, 11.3, 11.2, 11.1, 11.0, 10 or later
Linux, Mac, Windows
13.1, 12.2, 12.1, 12.0, 11.3, 11.2, 11.1, 11.0, 10 or later
Linux, Mac, Windows
13 May 2021
2755
v1.3: Nuke 13. compatible
v1.2: fixed bug to make the panel work with file paths without sequence padding (e.g. quicktimes, still frames, etc)
v1.1: added features:
- added tooltips
- option to turn off case sensitivity
- history menu for quick access of previous search&replace actions
- control the size of the history when creating the menu, e.g.:
1
srPanel = SearchReplacePanel.SearchReplacePanel( maxSteps=5 )
This was actually my first test project when python panels became available and has proven very handy tucked away in the pane menu for easy access.
To load the panel into the 'Pane' menu and make it save with layouts properly, drop something like this into your menu.py:
1 |
import SearchReplacePanel |
The above code in the menu.py will give you this:
You can chose to perform the search&replace on all nodes or just selected ones:
Please login in order to download these files.
Comments
Thanks!
http://www.nukepedia.com/video-tutorials/22/video/
The example code required to hook things up is on the top of the page.
Hope that helps.
I did modify the script by changing the "self.replaceSt r = nuke.String_Kno b" to a File_Knob as I primarily am change the file path and it just made it quicker and more convenient if I couldn't remember the exact file path. Plus it still works to replace anything even if I don't put in a file path
Again awesome script thanks Frank!
the link video not found
thanks
The link to the video works fine for me.
Mac OS High Sierra, NukeX 10 and 11 any versions.
Traceback (most recent call last):
File "/Users/d.dragu n/.nuke/myTools /scripts/menu.p y", line 55, in addSRPanel
myPanel = SearchReplacePa nel.SearchRepla cePanel()
File "/Users/d.dragu n/.nuke/myTools /scripts/Search ReplacePanel.py ", line 24, in __init__
self.history = nuke.Enumeratio n_Knob( 'history', 'Recent Searches', self.loadHistor y() )
File "/Users/d.dragu n/.nuke/myTools /scripts/Search ReplacePanel.py ", line 53, in loadHistory
xmlTree = ElementTree.par se( self.historyFil e )
File "/Applications/ Nuke11.1v2/Nuke 11.1v2.app/Cont ents/Frameworks /Python.framewo rk/Versions/2.7 /lib/python2.7/ xml/etree/Eleme ntTree.py", line 1182, in parse
tree.parse(sour ce, parser)
File "/Applications/ Nuke11.1v2/Nuke 11.1v2.app/Cont ents/Frameworks /Python.framewo rk/Versions/2.7 /lib/python2.7/ xml/etree/Eleme ntTree.py", line 657, in parse
self._root = parser.close()
File "/Applications/ Nuke11.1v2/Nuke 11.1v2.app/Cont ents/Frameworks /Python.framewo rk/Versions/2.7 /lib/python2.7/ xml/etree/Eleme ntTree.py", line 1665, in close
self._raiseerro r(v)
File "/Applications/ Nuke11.1v2/Nuke 11.1v2.app/Cont ents/Frameworks /Python.framewo rk/Versions/2.7 /lib/python2.7/ xml/etree/Eleme ntTree.py", line 1517, in _raiseerror
raise err
xml.etree.ElementTree.ParseError: unclosed token: line 1, column 363
https://drive.google.com/file/d/1iyjbiOVLXm-5NxhwkFfPO0tJ8SvgBKop/view?usp=sharing
it looks like the panel has trouble reading your history file. Can you show me the contents of your ~/.nuke/srhisto ry.xml ?
Try moving it away or renaming it to a temporary name and see if the panel comes up then (it should generate a new history file).
Cheers,
frank
In this file was next (I delete here brace, becouse this site don't let me write this on comment):
SearchReplacePanel
ITEM replace="080" search="190" /
ITEM replace="0050" search="0080" /
ITEM replace="0110" search="0050" /
ITEM replace="0020" search="0060" /
ITEM replace="0030" search="0020" /
ITEM replace="0030" search="0110" /
ITEM replace="0090" search="0030" /
ITEM replace="FOOTAG E" search="FOOTAGE " /
ITEM replace="footag e" search="FOOTAGE " /
ITEM
I use this all the time and haven't had this issue, so maybe you accidentally did something to the history file that caused it to become invalid xml syntax which would have caused the error you saw.
Let me know if it happens again and I will put a fail-safe in place when trying to read the history file.
in dont want to modifiy the main app menu so i use a launcher where i add some command like creation of compagny menu
it lauch the search and replace but it doesn't look like yours
here is my code,
import SearchReplacePa nel
menubar = nuke.menu("Nuke")
tbmenu = menubar.addMenu("&My_Compagny")
tbmenu.addCommand("Search and Replace Panel", "SearchReplaceP anel.SearchRepl acePanel() ")
#tbmenu.addCommand("Search and Replace Panel", SearchReplacePa nel.SearchReplacePa nel(),)
try:
if nuke.env[ 'studio' ]:
import SearchReplacePa nel
tbmenu.addComma nd("Reserve Frame Server Slaves", SearchReplacePa nel.SearchReplacePa nel(), "")
except:
pass
i also have trouble to integrate this line
nukescripts.registerPanel('com.ohufx.SearchReplace', addSRPanel)
as i dont use a def to appen to menu, i must also add that i'm very new to code :)
any idea ?
import SearchReplacePanel
menubar = nuke.menu("Nuke")
tbmenu = menubar.addMenu("&My_Compagny")
import SearchReplacePanel
def addSRPanel():
'''Run the panel script and add it as a tab into the pane it is called from'''
myPanel = SearchReplacePa nel.SearchRepla cePanel()
return myPanel.show()
#THIS LINE WILL ADD THE NEW ENTRY TO THE PANE MENU
tbmenu.addCommand('SearchReplace', addSRPanel)
#THIS LINE WILL REGISTER THE PANEL SO IT CAN BE RESTORED WITH LAYOUTS
nukescripts.registerPanel('com.ohufx.SearchReplace', addSRPanel)
i also change the addToPane by show wich is more convenient for me
thanx a lot for your script !
Any chances you would update the code to make it compatible with Python 3.0 so we can use it in NUKE 13? I use this tool a lot!
Thanks a lot!
Hi ! You can try it. I fixed for Nuke 13
DOWNLOAD HERE: https://bit.ly/3nZoMkw
That's awesome. I will remove my link.
replacing
Traceback (most recent call last):
File "C:\Program Files\Nuke13.0v 2\lib\sre_parse .py", line 1015, in parse_template
this = chr(ESCAPES[this][1])
KeyError: '\\U'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Program Files/Nuke13.0v 2/plugins\nuke_ internal\callba cks.py", line 127, in knobChanged
_doCallbacks(kn obChangeds)
File "C:/Program Files/Nuke13.0v 2/plugins\nuke_ internal\callba cks.py", line 46, in _doCallbacks
f[0](*f[1],**f[ 2])
File "C:/Program Files/Nuke13.0v 2/plugins\nukes cripts\panels.p y", line 23, in PythonPanelKnob Changed
widget.knobChan gedCallback(nuk e.thisKnob())
File "C:/Program Files/Nuke13.0v 2/plugins\nukes cripts\panels.p y", line 71, in knobChangedCall back
self.knobChange d(knob)
File "C:/Users/cg16/ .nuke/Python\Se archReplacePane l.py", line 174, in knobChanged
k.setValue( self.__doReplac e( k ) )
File "C:/Users/cg16/ .nuke/Python\Se archReplacePane l.py", line 162, in __doReplace
newStr = re.sub( m, self.replaceStr .value(), newStr )
File "C:\Program Files\Nuke13.0v 2\lib\re.py", line 192, in sub
return _compile(patter n, flags).sub(repl , string, count)
File "C:\Program Files\Nuke13.0v 2\lib\re.py", line 309, in _subx
template = _compile_repl(t emplate, pattern)
File "C:\Program Files\Nuke13.0v 2\lib\re.py", line 300, in _compile_repl
return sre_parse.parse _template(repl, pattern)
File "C:\Program Files\Nuke13.0v 2\lib\sre_parse .py", line 1018, in parse_template
raise s.error('bad escape %s' % this, len(this))
re.error: bad escape \U at position 2
Something different?
RSS feed for comments to this post