I am having a simple problem with Blender 2.76b using Python 3.4.2.

I'm trying to change the dimensions (not scale) of a mesh, and then put another object next to it, depending on the new size. However, after changing the dimensions (which works fine, the actual size in the animation changes) it still gives me the original dimensions when called.


add_cube  = bpy.ops.mesh.primitive_cube_add  
actor_name = bpy.context.scene.objects.active.name

#randomized size to check if post resize call is working:
sizex = random.randint(3,10)
sizey = random.randint(3,10)
sizez = random.randint(3,10)
bpy.data.objects[actor_name].dimensions = (sizex, sizey, sizez)
#end of random resize test

objdim = bpy.data.objects[actor_name].dimensions 
print('Actor Dimensions: ', objdim)

A standard cube is (2,2,2) big. When the code runs it changes the object size, but then prints "Vector((2.0, 2.0, 2.0))" when it should be bigger. Putting in static values instead of random numbers produces the same problem.

Running this in the python command line in the scripts window works fine, running from script does not. Am I missing some refresh thing?

Anyone come across this? It's like it's not refreshing the actual dimensions when I call them.


1 Answer 1


It seems the answer is to do a scene refresh after updating values. This works for this particular problem, but I suspect this issue is also elsewhere in the API.

Code up to 2.79:


For 2.8+ version:

  • 1
    $\begingroup$ bpy.context.view_layer.update() for Blender 2.8+ $\endgroup$
    – Math_Max
    Commented Jul 31, 2020 at 15:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .