Script request, prompt to name selected objects one by one?

wondering if someone has something floating around that would help naming a bunch of selected objects one by one.

  • select objects
  • one is chosen from the selected parts
  • highlights it
  • a window prompts to rename it
  • enter name
  • next part in selected set is selected
  • repeat until all objects are named individually

bonus: when it goes to the next object the rename field is prepopulated with the last entry.
example: if i enter TOOL for one part, when i get prompted to rename the next, the rename field has the previous entered value of TOOL so i can append custom delineations if needed.

bonus bonus: if the object is already named, have that populate the rename field so names can be edited too. the script just might do this naturally without any special code?

thank you.

Check out Peter’s Tools he has a few really nice scripts for exactly that.

@kleerkoat, below is some quick code to start from:

import rhinoscriptsyntax as rs

def MultiRename():
    
    obj_ids = rs.GetObjects("Select Objects to name", 0, True, True, False)
    if not obj_ids: return
    
    rs.UnselectAllObjects()
    
    last_name = None
    
    for obj_id in obj_ids:
        rs.SelectObject(obj_id, redraw=True)
        
        old_name = rs.ObjectName(obj_id)
        if not old_name: old_name = last_name
        new_name = rs.StringBox("Enter new object name", old_name, "MultiRename")
        if new_name:
            rs.ObjectName(obj_id, new_name)
            last_name = new_name
        
        rs.UnselectObject(obj_id)
        
MultiRename()

_
c.

1 Like

thank you, downloading now!

my man @clement always come through with something golden! thank you.

1 Like