Motivation: I would like to add multiple empties with sequential, but meaningful, names using the Python API with Blender.
Issue: I cannot name the objects as I add them.
Question: What can I add to the bpy.ops.object.add()
code to give a name, or how can I change the name immediately after adding the object?
So far, to insert empties with (x,y,z) coordinates (1.1,1.1,1.1), (2.2,2.2,2.2), (3.3,3.3,3.3), and (4.4,4.4,4.4):
import bpy
x = (1.1,2.2,3.3,4.4)
y = (1.1,2.2,3.3,4.4)
z = (1.1,2.2,3.3,4.4)
for index,val in enumerate(x):
bpy.ops.object.add(type='EMPTY', location=(x[index],y[index],z[index]))
They are added with sequential names:
- Empty.001
- Empty.002
- Empty.003
- Empty.004
Here is a screenshot of the output: Screenshot of Blender after running Python script
But, I want them to have names:
- SpecifiedName.001
- SpecifiedName.002
- SpecifiedName.003
- SpecifiedName.004
I cannot seem to just add the property name = "SpecifiedName" to read:
bpy.ops.object.add(type='EMPTY', location=(x[index],y[index],z[index])) ###DOES NOT WORK!!!###
If you are curious as to the final outcome I am looking to do, I want to plot several different datasets in x,y,z coordinates. Each empty from each dataset (and cooresponding name) will be linked to an mesh like a sphere or cube. This gives me the chance to animate a flythrough or rotation of 3D scatter plot data.