A little tool used with Maya to replace the default renaming tool.
Video showcase: https://vimeo.com/726886513
I made this tool over the summer as a way to learn and practice python. The goal when creating this tool was to replace Maya's old renaming tool for something a little more versatile and powerful.
The tool currently is currently separated in 5 parts to allow users the following renaming options:
- Replace - Querries a string in selected objects' names and replaces it with target name.
- Rename - Replace selected objects' names with a new one, or add a prefix/suffix to the current name.
- Quick Prefix/Suffix - Quickly add common prefixes/suffixes to current name.
- Quick Remove - Quickly remove characters or target string from current name.
- Quick Selection - Quickly select hierarchy and filter selection by common object types.
Here are some other functions that help the code run smoothly and enable other quality of life features:
Because of the selection order, normally the code could rename objects higher in a hierarchy first. This isn't ideal as this changes the path of other stored object names. To circumvent this issue, I opted to rename objects in my list by path length, starting with the longest path. The original selection order is then stored for selection order dependent variables like incrementation number.
UI is dynamically updated to accurately represent the final result of quick add buttons when enabling the Uppercase or Prefix bool.
To better understand what the tool is doing (or why it isn't operating as intended), commands have tailored feedback and errors provided in the console.
A simple function to quickly access a list, and items within the list if necessary.
A simple set of functions to quickly access all selected items, selected items and their hierarchy or all objects in the current scene.
- Copy the "jdd_outlinerBuddy.py" to your Maya scripts directory:
MyDocuments\Maya\scripts\
- Then, within maya, use the following text as a python script to run the tool:
import jdd_outlinerBuddy as OB
OB.UI()
- (Optional) Alternatively, the text can be saved in the custom shelf using maya's script editor. This makes the script a small button in your current shelf so it can easily be accessed later.
- Attempting to remove the last character on a duplicate name is impossible, since Maya will keep adding a number at the end. Try removing 2 or more characters in those instances to avoid creating a duplicate name.
- Object names in Maya can only start with letters or underscores. If an operation creates an illegal name, that operation will either add text in front of the new name ("char__") or raise an error message instead.
- When using incrementation in the 'rename' section of the tool, the first number happens to be wrong on occasions. Pressing the rename button again after that solves the issue