先贴个代码,待会解释。
#
# Renaming Tool by Clement Chaudat - 2014 v1.1.0
#
# CONSTANTS IN TEXTFIELDS
# Multiple constants with right-click on textField:
# - OldName: good for prefix/suffix
# - ObjectType
# - ParentName
#
# INCREMENT: "###" or "%3d"
# Right-click on textField then "Set Start/Step" for
# start number and step value for indent.
#
# RENAME USING REGEXP:
# example : "end$" will replace "end" at the end of the name
# "^start" will replace "start" at the beginning of the name
#
import re
import functools
import maya.cmds as cmds
from maya import OpenMaya
uiFile = """<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="winRenamer">
<property name="geometry">
<rect>
<x>120</x>
<y>120</y>
<width>320</width>
<height>100</height>
</rect>
</property>
<property name="windowTitle">
<string>Rename / Replace</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>4</number>
</property>
<property name="margin">
<number>4</number>
</property>
<item>
<widget class="QLineEdit" name="cc_edit_rename"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="cc_check_replace">
<property name="text">
<string>Replace By:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="cc_edit_replace">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QRadioButton" name="cc_check_all">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>All</string>
</property>
</widget>
&