Blender 2.6: Select object by name through Python Blender 2.6: Select object by name through Python python python

Blender 2.6: Select object by name through Python


bpy.data.objects['OBJECT'].select = True

Selection data is contained within the individual objects. You can read and write them as shown. In a slightly more readable form:

object = bpy.data.objects['OBJECT']object.select = True


bpy.ops.object.select_name() has been replaced by bpy.ops.object.select_pattern() (around 2.62, I think?), which is a more powerful version (it can select an exact name, but also use patterns with wildcards, be case-insensitive, etc.):

bpy.ops.object.select_pattern(pattern="Cube")


import bpydef returnObjectByName (passedName= ""):    r = None    obs = bpy.data.objects    for ob in obs:        if ob.name == passedName:            r = ob    return robs = bpy.data.objectsbpy.ops.object.select_all(action='DESELECT')for ob in obs:    print (ob.name)    myObj = returnObjectByName(ob.name)    if myObj != None:        print (dir(myObj))        myObj.selected = True        myObj.location[2] = 10        myObj.selected = False

Not my code, not guaranteed to work.

Source