getting ob in scene

i created an object with name of mesh = name of object and can see it in the button window F9

so i know it is there and ok

but when i try to get the object with the following code

ob =Blender.Object.Get( NAME )
print ‘ob name=’,

the name printed is nill

how come i cannot get the object with the right name ?


It looks like you didn’t bother to check if the call actually worked, you simply assumed you would get an object back.

I offer up my fetchIfObject code (once again):

def fetchIfObject (passedObjectName):
    # NOTE: Returns the object even if it is unlinked to the scene.
        tempObj = Blender.Object.Get(passedObjectName)
        return tempObj
        return None


    sourceObj = fetchIfObject ("myObjectName")
    if sourceObj != None:

but if i can see the name in F9 for the mesh and object it should be already link to the scene?

i’ll do a complete list of all objects and see if it is there


it should work, linked or not… ? :confused:

from Blender import *


print ob.getName()

your issue has maybe another origin. maybe your variable names that could conflict with functions.
test with a fresh cube object.
you can also try to add your script in a fresh file, adding code litle by little.

Yep, make sure your variable name is not a reserved word.

it is possible that because i had already an object name like that the new object name took the same name.+ 001
and the rotation was applied to the first old object

it looks that the old object was not rename and kept it’s original name

the new object took the new name as such but a number was also adde to it

like name = spiral and in blender it became spiral…001

but in the script i already had the name spiral not spiral.001 so it could not find it !

but is there a way to give to an object an absolute name with no chang ein blender like adding number to it or how do ig et the real name given in blender so i can change the spec of the added object ?

another thing here is if you have 2 objects with same name let say
spriral and spira.001 and you delete spiral then copy the spiral.001 it won’t take the name spiral.002 it will take the name spiral again !

so that complicate things a little

thanks for the help

You must come up with a name management system from the begining. I faced the same problem when I wrote Blendgraph and Meshfoot.

Don’t ever let Blender name your objects!

i mean this is a sript to add objects with a specific name

but blender change the name by adding a number if it already exsit in scene

so how can you deal with this situation so that you don’t hve this problem and always get unique name

it’s when i add a new object with name i need to do things on this object like rotate
or re locate or scale or to modify the mesh ect…

normally i do that immediately after creating the object
but if the name is already change by internal blender i cannot use the name given
because it’s been changed?


Once again fetchIfObject comes too your rescue. Before you attempt to create an object, you need to see if already exists! If it does, simply re-use the object and don’t create a new one.

    sourceObj = fetchIfObject ("myObjectName")
    if sourceObj != None:
        # Go ahead and create an object.
        # No need, source object already exists.
    # Now I can operate on my object.

You might want to browse the Blendgraph library. It is inside the BLEND file at this link:

Even if you don’t use the code, maybe some of the function names might spark a design approach to your current script.