I want to add another menu item to my Custom Panel for scaling the size of an object by +2. I get the following code whenever I do the scaling.

bpy.ops.transform.resize(value=(2, 2, 2), constraint_axis=(False, False, False),
constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', 
proportional_edit_falloff='SMOOTH', proportional_size=1)

How do I pass this code to col.operator() so it works as at the moment I am getting an error.

This is my current code which works fine and allows me to add a plane or cube object.

import bpy

class CustomPanel(bpy.types.Panel):
    """A Custom Panel in the Viewport Toolbar"""
    bl_label = "Custom Panel"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'TOOLS'

    def draw(self, context):
        layout = self.layout

        row = layout.row()
        row.label(text="Add Objects:")

        split = layout.split()
        col = split.column(align=True)

        col.operator("mesh.primitive_plane_add", text="Plane")
        col.operator("mesh.primitive_cube_add", text="Cube")

def register():

def unregister():

if __name__ == "__main__":

1 Answer 1


If all you want to set for the operator is a single property, you can do:

col.operator("transform.resize").value = (2,2,2)

If you want to set multiple properties, use the object that is returned by .operator() and set the properties on it one after another:

props = col.operator("transform.resize")
props.value = (2,2,2)
props.constraint_orientation = 'GLOBAL'

You must log in to answer this question.

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