Search code examples
pythonlistblenderbpy

Is it possible to split the elements of a list?


>>> a = bpy.context.selected_objects
>>> a[:2]
[bpy.data.objects['Sphere.001'], bpy.data.objects['Sphere.010']]

>>> 

Two list results.

what i need is It is to move the number after Sphere to notepad. I do not know.

001 and 010

thank you.


Solution

  • Is this what you want?

    for a in bpy.context.selected_objects:
        print(a.name.split(".")[-1])
    

    In Blender, you can just split the object's name on the '.' and take the last element in the resulting list. That should print out all those numbers that you want to copy.