Help with 'Search and replace name'

Help with 'Search and replace name'

Anonymous
Not applicable
12,416 Views
7 Replies
Message 1 of 8

Help with 'Search and replace name'

Anonymous
Not applicable

Hi

 

I'm working in a rather large scene where a lot of the same geometry is being duplicated, leading to things getting lots and lots of numbers after their names. ex DWall_Geo29, DWall_Geo30 etc.

 

There is probably some mel script that can help me, I'm just not that good with mel programming.

 

So I'm using search and replace.

I figured out that if you use \$ in the search for field it appends what ever you've got in the replace field to the existing name. 

 

So My question becomes, is there a short hand expression to just replace the existing name entirely with what is in the replace field?

0 Likes
Accepted solutions (1)
12,417 Views
7 Replies
Replies (7)
Message 2 of 8

Nadja.Bueckmann
Alumni
Alumni

Hi @Anonymous,

 

could you explain to me in more detail, perhaps with the DWall example you posted, what you want to achieve in the end?

How should the objects be named after the operation?

 

Best, Nadja



Nadja Bueckmann

Technical Support Specialist – M&E (3ds Max, Maya)

0 Likes
Message 3 of 8

Anonymous
Not applicable

Hi

 

What I would like to achieve is to simply mass rename objects that are inside their own separat groups with the same name. 

To use my concrete example of what I'm working on right now:
I've got groups that are named:

 

MDP_FP_Dungeon_DWall_Divider_TopFloor

MDP_FP_Dungeon_DWall_Divider_MidFloor

MDP_FP_Dungeon_DWall_Divider_BottomFloor

MDP_FP_Dungeon_DWall_Divider_SingleFloor

etc. (there are 130+ of these groups)

These groups a variations of each other, so I can't simply fix one group and duplicate that group out finished and do adjustments. This has to do with me having to combine geometry with same material after it has been specialized(rotated, transformed, duplicated and optimized) inside each group.

 

Now, inside each of these groups I have 2-3 different geometry types. I have a wall geo, a pillar geo and a support geo. As I stated above these get adjusted and combined in various ways inside each group and thus their names become messed up. But in the end they all end up with being 1 wall geo, 1 pillar geo and 1 support geo. 

 

So what I would like is to rename the final wall geometries, inside each group, in one operation. Same goes for the pillars and support geos. Now as you can imagine all those walls get different names after getting combined/duplicated/etc. so search and replace can't do it unless there is a shorthand sign to tell search and replace that all selected objects are to be renamed with what ever I've placed in the 'replace with' box. Like if I place '\$' in the search box it appends what ever I've placed in the 'replace with' box to the exiting name.

 

My workaround that I've come up with is a mel script that simply does rename any selcted object that is selected with what ever is in the script, But I have to go into the script every time I want a different name. It would be much easier if there was just a shorthand code to place inside the search box instead.

0 Likes
Message 4 of 8

Nadja.Bueckmann
Alumni
Alumni

Hi @Anonymous,

 

thanks a lot for the great description.

You can do this with another method:

  1. Select the objects.
  2. Open the pop-up menu next to the input field(s) on the Status line and select Rename.
  3. Type the base name for all the objects. Maya renames the objects to have the base name plus an incremental number

Best, Nadja



Nadja Bueckmann

Technical Support Specialist – M&E (3ds Max, Maya)

0 Likes
Message 5 of 8

Anonymous
Not applicable

Nice. But, as you state this gives numbers at the end of the names which I do not want. I need to have a consistent naming convention 😕

0 Likes
Message 6 of 8

Anonymous
Not applicable

This is the way I want it to look in the end.

 

And this is the size of my hierarchy so far, and it will gro a lot more before I'm finished with this project 😛

0 Likes
Message 7 of 8

Nadja.Bueckmann
Alumni
Alumni
Accepted solution

Hi @Anonymous,

 

I found a way for you to solve your issue with a little bit of Mel magic:

Please select the nodes you want to rename, type the new name into the status line but do not hit enter.

Instead run this script (on a shelf button to make it easier):

 

global string $gTextualInputField;

string $newName = `textField -q -tx $gTextualInputField`;

string $node;

for( $node in `ls -sl` )

{

    rename $node $newName;

}

 

I´m looking forward to your reply if this works,

Best,

Nadja



Nadja Bueckmann

Technical Support Specialist – M&E (3ds Max, Maya)

0 Likes
Message 8 of 8

Anonymous
Not applicable

Perfect!

 

This was just what I was looking for! Thank you so much, you are awesome!

 

You have saved me a lot of time 🙂

0 Likes