Shortcut for renaming Object to existing named Object?

 From:  Michael Gibson
3375.3 In reply to 3375.1 
Hi Hamish, here's a script that I think can help you out:

script: /* Match object name */ var name = ''; var objects = moi.geometryDatabase.getObjects(); for ( var i = 0; i < objects.length; ++i ) { var obj = objects.item(i); if ( obj.selected && obj.name != '' ) { name = obj.name; break; } } if ( name != '' ) { for ( var i = 0; i < objects.length; ++i ) { var obj = objects.item(i); if ( obj.selected && obj.name == '' ) { obj.name = name; obj.selected = false; obj.selected = true; } } }


To set up the script, go to Options > Shortcut keys, add in a new entry and paste in the above as the command part of the shortcut key.


The script works purely off of selection - to use it you must make a combined selection that includes at least one of the objects that already has the name assigned to it, along with other unnamed objects that you want to have assigned to that same name.

When you have a selection set up like that, then push the shortcut key and it will assign the unnamed objects to have that same name.

You can use the Scene browser to help you make the selection - right click on the object name in the scene browser to make it the "isolated selection" - everything else will get deselected and only those named objects will be selected. Then select the unnamed objects and then push the shortcut key.


I do have a plan for making this easier in the future - I want to have a drop-down menu that you can pop out from some things in the scene browser and one of the things I want to put on that menu is "assign to this name". That is part of the stuff that I also want to add in for Groups support when I get a chance to work on that area again in v3.

- Michael