On this page |
How to ¶
To... | Do this |
---|---|
Change name of a single node |
In the network editor, click the name of the node (next to the node body). Or, select the node and press F2. |
Tip
Houdini automatically updates any existing references to the node in the scene. You don’t have to worry about renaming a node breaking expressions.
Find and replace across all node names ¶
To... | Do this |
---|---|
Find and replace text/patterns in all node names at once |
The table below the controls shows a live preview of the renames that will happen if you click Rename or press Enter. |
Rename nodes in multiple networks at once |
You can enter a space-separated list of directory path patterns in the In path field to specify multiple networks to rename inside. |
Tip
If you want to match nodes to rename using criteria other than their names, first use the Find dialog to select the nodes you want to rename, then chooe Edit ▸ Rename Nodes and turn on Find in selected to make the rename only operate on those nodes.
Patterns (advanced) ¶
-
You can use glob patterns in the find and replace strings. The special characters are the same as standard Houdini patterns, with the addition of
#
to mean a sequence of digits.*
Matches any number of characters.
#
Matches one or more digits. For example,
1
,0005
, or50607
.?
Matches any single character.
[‹chars›]
Matchs any of the characters in the brackets. For example,
[abc]
matchesa
,b
, orc
.[‹start›-‹end›]
Matches any of the characters in the given range. For example,
[a-z]
matches any lower-case letter froma
toz
(inclusive).[!‹chars›]
Negates a character set/range, so it matches any chars other than than characters in the set/range. For example,
[!a-m]
would match any characters other than lower-case letters froma
tom
. (Note this syntax is not available in regular Houdini globs.) -
The text matching a pattern (any group of special characters) in the Find text will be used to replace a corresponding pattern in the Replace text.
Find
Replace
left_*
right_*
Before
After
left_arm
right_arm
left_foot
right_foot
-
If the Find text has more than one pattern, they will replace corresponding patterns in the Replace text by position (for example, the first
*
in the Find will replace the first*
in the Replace, the second will replace the second, and so on).Find
Replace
*_alpha_*
*_beta_*
Before
After
lamp_alpha_matt
lamp_beta_matt
window_alpha_lee
window_beta_lee
-
If patterns have distinctive text, you can move them around and Houdini will match them up by the pattern text:
Find
Replace
*_???
old_???_*
|Before
After
lamp_esr
old_esr_lamp
window_jwz
old_jwz_window
-
You can use
$1
,$2
, etc. in the Replace text to refer to the match of a pattern in the Find text by position. For example,$1
will be replaed with the match to the first pattern in the Find:Find
Replace
*_*
$2_$1
Before
After
lamp_new
new_lamp
window_final
final_window
Tip
When counting pattern positions, each of the following counts as one:
-
An asterisk (
*
) -
A number sign (
#
) -
One or more question marks (
?
) -
One or more character ranges (
[]
)
So, for example, the Find text
*#_???
has three patterns:*
,#
, and???
. -
-
You can negate part of the find pattern by putting
^
in front of it. This is mostly useful for excluding names that start with or end with a certain string. For example,^beta_*
matches names that don’t start withbeta_
.A
^
character will negate the next “part” of the pattern. Each of the following counts as a part:-
One or more literal characters
-
An asterisk (
*
) -
A number sign (
#
) -
One or more question marks (
?
) -
One or more character ranges (
[]
)
If you include a negative match in the find pattern, the find pattern must match the entire name (as if Match Whole Name was on).
Note
Negation works differently in the rename dialog than in regular Houdini globs, because the regular behavior isn’t very useful for renaming.
-
Examples ¶
To… |
Find |
Replace |
---|---|---|
Remove a prefix |
|
|
Add a prefix |
|
|
Remove a suffix |
|
|
Add a suffix |
|
|
Replace a prefix |
|
|
Replace a suffix |
|
|
Remove everything up to and including a double-underscore |
|
|
Add |
|
|
add |
|
|
Scripting ¶
If you have a hou.Node reference to a node, you can change its name with hou.Node.setName:
>>> node = hou.node("/obj/geo1") >>> node.setName("table_lamp")
To do a mass-rename in a script, you can use the nodeutils.rename_nodes()
function:
from nodeutils import rename_nodes success = rename_nodes(network, find, replace, selected=False, whole_name=False, errors=None, fail_fast=False, unique_name=False, ignore_case=True)
The rename_nodes
function takes the following arguments:
network
A hou.Node object representing the parent network in which to perform the renames.
find
A string representing the text/pattern to find (see patterns above).
replace
A string representing the text/pattern to replace matches with (see patterns above).
selected=False
If True, the function only considers the currently selected nodes in the network to rename.
whole_name=False
If True, the find
pattern must match the entire node name, not just a substring.
errors=None
If you supply a list in this argument, the function will append a ("oldname", "newname", "errormessage")
tuple to the list for each rename that fails (for example, because the new name is invalid, or already used).
unique_name=False
If this is True, when a rename would conflict with an existing name, Houdini will add/increment a number at the end of the new name to make it unique. This means no rename will fail because a name is already in use, but the new names may not be exactly as you expected. There may still be failures if the “find” and “replace” patterns generate an invalid node name.
ignore_case=True
Ignore uppercase/lowercase differences when comparing node names to the find pattern.
fail_fast=False
If this is True, the function stop and return when a rename fails. By default, the function ignores failures and goes on trying to perform the rest of the renames.
Returns
True
if all renames completed without error, or False
otherwise.
The rename_nodes
function puts the renames in an undo block. You can undo the renames that succeeded with hou.undos.performUndo.