So I've very new to Blender coding. Here's what I'm trying to do:

cubeobject = bpy.ops.mesh.primitive_cube_add
cubeobject.scale = (-2.2,0,0)

I can't get this to work. I've tried SizeX settings and other translate functions, but nothing seems to work. I'm sure that reference method is wrong, but I've combed the forums for 20 mins with no progress.


What to do

You need to play around with the python console for this stuff.

Here is probably what you want (sets the value directly in the properties panel, absolute method):

bpy.context.scene.objects.active.scale = (-2.2, 0, 0)

You may also want to scale like this (scales object the same way as pressing S in the 3D view, relative method):

bpy.ops.transform.resize(value=(-2.2, 0, 0))

When an object is created, it is selected and set active so my examples will work in a simple case like this without a reference to the object.

Why your script won't work

  1. bpy.ops.mesh.primitive_cube_add doesn't do anything useful (it won't create an object)
  2. bpy.ops.mesh.primitive_cube_add() only returns {'FINISHED'} not a reference to the new object.

I think what you need is transform.resize. It's not scale :)


  • $\begingroup$ What's the easiest method of examining the class tree maps? As in one path is used to create an object, and another path is used to modify that object. I see great docs on individual commands, but no master tree diagram. Still searching. $\endgroup$ – Dr Tyrell Aug 29 '16 at 21:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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