0
$\begingroup$

For example, the command to create a cube is:

bpy.ops.mesh.primitive_cube_add(view_align=False, 
                                enter_editmode=False, 
                                location=(0.0, 0.0, 0.0), 
                                rotation=(0, 0, 0), 
                                layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))

But how do you specify its name so it's not automatically determined (e.g. Cube.001)?

$\endgroup$
0
1
$\begingroup$

After some more searching I found the solution here Adding Named Objects in Blender with Python API

The following example creates five cubes with names 'LittleCube000', 'LittleCube001', 'LittleCube002', 'LittleCube003' and 'LittleCube004'

for i in range(5):
   add_cube(location = (i*2, 0, 0))
   bpy.context.active_object.name = 'LittleCube{:03}'.format(i)

You can also find an object named 'OldName', and updated to 'NewName':

object = bpy.data.objects.get('OldName')
if object:
    object.name = 'NewName'

However, if 'NewName' is already in use, then a numerical suffix will be automatically added to it.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.