renaming objects


I’m experimenting with python in 2.49 and trying to rename an object. I have something like

print "The name of the object is: ",ob.getName()
>>> MyCone

but I want to rename it to … :confused:… say ‘Conical’, is that possible?



The following changes the name of 1 object to “Conical” or ALL selestec objects to the same name with numbers at the end:

def Ren_current_object(st):
    sce = Scene.GetCurrent()
    ob = Object.GetSelected()[0] = st

def Ren_sel_objects(st):
    sce = Scene.GetCurrent()
    sel_objects = Object.GetSelected()
    for i in range(len(sel_objects)):
        ob = sel_objects[i] = st+"_"+str(i)

editmode = Window.EditMode()
st = "Conical"

If you need to use the multi-renaming version, you need to uncomment it first, i.e. remove the # before Ren_sel_objects(st).

Both procs suppose there is NO such name (or names) prior to applying the new names. Otherwise, you will get something like “Conical.001”. In such a case you will need to (1) identify there is already an object with such a name; (2) decide what to do in this situation, i.e. remove that name to something else, for example; (3) apply your new name.


Why not using Blender 2.53???
There you code like this.
obj = … (eg. bpy.context.active_object) = “new name”
The name of an object is read/writable :wink:

Can you explain that better for 2.53?

Question to ???

If you go to the Scripting possibility and look there at the Python -console.
Type e.g.

if you save this as a list e.g.:
allobjs =
you can access each, look for its name and change the name to your wishes
or if you know allready the name (blabla eg.) you work e.g. like this:
myobj =[“blabla”] = “not anymore”
and your object has now the name notanymore

In a script you use commands like the shown ones …

Thanks PKHG, that’s really awesome :slight_smile: I don’t know very much about Python, but how about if I don’t want to care about the already existing names of objects. Just wanting to rename (in 2.5x) whatever is selected by order. But I don’t know where to go from here:

import bpy
allobjs = = “something”

I know the steps, but I have trouble translating that to code:

  1. Know what objects the user has selected.
  2. Get their values
  3. Change their values to an established name plus a number

You mean something like the example Abidos gave (for 2.49)?

If I understand correct:
The user has selected several objects and want to give them a name|
myname01, myname02 … myname14 (if 14 objects were seltected with whatever name?)
And that by using a script with name = “myname” the rest automatically?

import bpy
def renameSeletedToNumbered(name):
    counter = 0
    ao =
    for el in ao:
            print("name now is ",
            counter +=1
   = name + str(counter)
            print("new name is",
name now is  Cube
new name is aaa1
name now is  Curve
new name is aaa2
name now is  Monkey
new name is aaa3

That’s amazing! Thank you :smiley: