Object name

 From:  Michael Gibson
5710.20 In reply to 5710.18 
Hi mir4ea,

> So what I need is shortcut that will assign unic name to SELECTED geometry, without any dialogs. Thank you)

Here's a script that will do that - paste in the below script. Then when you run it if you have selected 4 objects for example the first will be named object_0001, the second object_0002, etc... with each object getting a unique name. If there is another object already named object_0002 it will skip that name and keep increasing the number until it finds an unused one.

script: /* Assign unique names to selected objects */ var all_objects = moi.geometryDatabase.getObjects(); var used_names = new Array(); for ( var i = 0; i < all_objects.length; ++i ) { var obj = all_objects.item(i); if ( obj.name != '' ) { used_names[obj.name] = true; } } var selected_objects = moi.geometryDatabase.getSelectedObjects(); var counter = 0; for ( var i = 0; i < selected_objects.length; ++i ) { var obj = selected_objects.item(i); if ( obj.name != '' ) { continue; } var name; while ( 1 ) { var numtag = counter.toString(); while ( numtag.length < 4 ) { numtag = '0' + numtag; } name = 'object_' + numtag; if ( used_names[name] ) { ++counter; continue; } used_names[name] = true; break; } obj.name = name; }


I'm not entirely sure if that is what you wanted, did you mean you wanted the entire selection to all have the one same unique name rather than each individual object inside of the selection getting its own unique name?

It still seems like you're trying to do something kind of unusual by avoiding styles though, I don't understand why you wrote previously that you can't assign one material to multiple objects, you should definitely be able to do exactly that...

- Michael