Skip to content

Instantly share code, notes, and snippets.

@haxpor
Created January 15, 2017 17:38
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save haxpor/198f6993a62a21279519fcd0fbb36726 to your computer and use it in GitHub Desktop.
Save haxpor/198f6993a62a21279519fcd0fbb36726 to your computer and use it in GitHub Desktop.
Blender Python script to create a new cube, rename it along with set its to new location
import bpy
def strVector3( v3 ):
return str(v3.x) + "," + str(v3.y) + "," + str(v3.z)
# create a new cube
bpy.ops.mesh.primitive_cube_add()
# newly created cube will be automatically selected
cube = bpy.context.selected_objects[0]
# change name
cube.name = "MyLittleCube"
# change its location
cube.location = (0.0, 5.0, 0.0)
# done
print("Done creating MyCube at position " + strVector3(cube.location) + " with name " + cube.name)
@pTinosq
Copy link

pTinosq commented Jun 24, 2020

Very useful, thanks.

@dacre-denny
Copy link

Thank you

@jroll777
Copy link

Thank you very much

@tundeesho
Copy link

Thanks.

@Ivan-Malin
Copy link

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment