Script to setobject name in particular sequence

is there anyone who can write script to setobjectname as Name1.
i mean each time it gets executed it should check for last name and then it should increment the number by 1. like for next time it should setobject name as Name2 and so on.

oh sorry, i have done it using chatgpt and bind it to F2 to press quickly.

posting here if anyone wants it. This is useful as

  1. we work in hurry and want to quickly name our object a sequence name so we can later use it for selection and give other properties like layer, user text and others.
  2. the object copy generated will have same name so we can select them by SelName command.
  3. It will be useful to select object based upon their sequence so we can track our object creation and utilize SelName command based upon it.

import rhinoscriptsyntax as rs

def set_object_name():
# Base name to start with
base_name = “Name”

# Get all object identifiers in the document
all_objects = rs.AllObjects()

# Get existing object names
existing_names = [rs.ObjectName(obj_id) for obj_id in all_objects if rs.ObjectName(obj_id) is not None]

# Determine the next available number in the sequence
i = 1
new_name = base_name
while new_name in existing_names:
    i += 1
    new_name = "{}{}".format(base_name, i)

# Prompt the user to select objects
objects = rs.GetObjects("Select objects to rename")

if objects:
    # Rename each selected object with the determined name
    for obj in objects:
        rs.ObjectName(obj, new_name)
        print("Set name of object {} to '{}'".format(obj, new_name))
        existing_names.append(new_name)  # Add the new name to the list of existing names

else:
    print("No objects selected.")

Run the function

set_object_name()