Skip to content

Instantly share code, notes, and snippets.

@CGArtPython
Created January 31, 2023 06:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CGArtPython/f758b625521d39ce950cbfc7f5a0d451 to your computer and use it in GitHub Desktop.
Save CGArtPython/f758b625521d39ce950cbfc7f5a0d451 to your computer and use it in GitHub Desktop.
Add a cube into the scene and update the hight
import bpy
custom_size = 5
# add cube into the scene
bpy.ops.mesh.primitive_cube_add(size=custom_size)
cube_obj = bpy.context.active_object
# move the cube up half way on the Z axis
cube_obj.location.z = custom_size / 2
# set the origin of the cube to the cursor location
bpy.ops.object.origin_set(type="ORIGIN_CURSOR", center="MEDIAN")
# scale the cube on the Z axis
bpy.context.active_object.scale.z *= 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment