It does actually change the name of the cube to “newcube”, when I test it. No idea why it isn’t working for you.
By the way, when you post code on the forum, try to use the code tags. It helps to preserve indentation.
# cube
bpy.ops.object.mesh_add(type='CUBE')
for ob in bpy.data.objects:
if ob.name == "Cube":
# print all of MyObject's vertex coordinates
for vert in ob.data.verts:
print(vert.co)
if ob.selected:
ob.name="newcube"
print ( "End of vert list")
You use it like this (just remove the asterisk *) :
The script I posted is the one you posted, I just added proper indentation. So that’s probably what is wrong in yours.
If you don’t have the last block of code (if ob.selected: etc.) indented, it will only be run once: for the last object in the scene. If that isn’t your newly added object, there will be no re-naming.
About making a window longer: just drag the devision line between two windows. You can also maximize a window by pressing Ctrl+Up (just like in 2.4x).
In the default scene there already is a cube present, named ‘Cube’. When you add a new mesh (another cube), it’s automatically called ‘Cube.001’
After that you start iterating over all the objects in the scene but only do something if the object is called ‘Cube’. This is the orginal cube that was already in the scene, not the newly created one. Unfortunately the original cube isn’t selected anymore, because when you added the new cube, blender automatically set that cube to be the only selected object. So the last ‘if’ statement (original cube being selected) will never be true, hence there’ll be no renaming.
i tough that ounce you go trhough all the objects as soon as it goget the Cube one
the IF inside the foor loop would recognise it
but does not seems to do that for my original script
but the same is true with yours how can the" if" find it outside of the for loop
the second cube as already been added and selected ?
and what is stange as i said the second cube was not named Cube.001 it was called “Mesh”?
i hope we can get a better way to select objects in 2.5