Albertofx
(Alberto Gonzalez(afx))
1
I’d like to check if an object exists, otherwise add a cube & name that object “Box”
I tried this, but it didn’t seem to work:
if bpy.data.objects["Box"] == 'True':
pass
else:
bpy.ops.mesh.primitive_cube_add(size=2)
ob = bpy.context.active_object
ob.name = "Box"
Hey Alberto, I’ve been using this method:
found = 'Primitives' in bpy.data.objects
if found == 1:
obj = bpy.data.objects['Primitives']
so i guess in your case just set found == 0 and make your box
1 Like
Albertofx
(Alberto Gonzalez(afx))
3
Awesome! thank you so much.
1 Like
AFWS
(AFWS)
4
This is how I’d do it.
if "Box" in bpy.data.objects:
pass
else:
bpy.ops.mesh.primitive_cube_add(size=2)
ob = bpy.context.active_object
ob.name = "Box"
1 Like