Python
def delete_suffixHierarchy_remove_suffix(self,suffix):
print("-----------prefixHierarchy_remove_suffix-----------start")
#suffix="fat:"
# Get the prefix the user entered
#
# Get a list of all descendents (The nodes are ordered from
# leaf to root
#
currentNodes=pm.mel.eval("listRelatives -pa -ad `ls -sl -l`")
print("currentNodes 1= "+str(currentNodes))
# add the prefix to each descendent node
#
if len(currentNodes)>0:
for i in range(0,len(currentNodes)):
#pm.mel.prefixNode(prefix, currentNodes[i])
newName=currentNodes[i].replace(suffix,"")
print("newName= "+newName)
cmds.rename(currentNodes[i], newName)
currentNodes=cmds.ls(l=1, sl=1)
print("currentNodes 2= "+str(currentNodes))
# get a list of nodes on the list
# add the prefix to each node on the active list
#
if len(currentNodes)>0:
for i in range(0,len(currentNodes)):
#pm.mel.prefixNode(prefix, currentNodes[i])
newName=currentNodes[i].replace(suffix,"")
print("newName= "+newName)
cmds.rename(currentNodes[i], newName)
print("-----------prefixHierarchy_remove_suffix-----------end")
mel
global proc prefixHierarchy( )
{
string $ok = (uiRes("m_prefixHierarchy.kOK"));
string $cancel = (uiRes("m_prefixHierarchy.kCancel"));
string $result = `promptDialog
-title (uiRes("m_prefixHierarchy.kPrefixHierarchy"))
-message (uiRes("m_prefixHierarchy.kEnterPrefix"))
-text "prefix_"
-button $ok
-button $cancel
-defaultButton $ok
-cancelButton $cancel
-dismissString $cancel `;
// If the result was "OK", then proceed
//
if ( $result == $ok ) {
// Get the prefix the user entered
//
string $prefix = `promptDialog -q`;
// Get a list of all descendents (The nodes are ordered from
// leaf to root
//
string $currentNodes[] = eval("listRelatives -pa -ad `ls -sl -l`");
// add the prefix to each descendent node
//
if ( size( $currentNodes ) > 0 ) {
for( $i=0; $i < size( $currentNodes ); $i++ ) {
prefixNode( $prefix, $currentNodes[$i] );
}
}
// get a list of nodes on the list
$currentNodes = `ls -sl -l`;
// add the prefix to each node on the active list
//
if ( size( $currentNodes ) > 0 ) {
for( $i=0; $i < size( $currentNodes ); $i++ ) {
prefixNode( $prefix, $currentNodes[$i] );
}
}
}
}
コメント