# How to bpy.ops.transform.resize in edit mode using pivot?

**URL:** <https://blenderartists.org/t/how-to-bpy-ops-transform-resize-in-edit-mode-using-pivot/560381>\
**Category:** Python Support\
**Created:** [December 24, 2012, 9:59am UTC](https://blenderartists.org/t/how-to-bpy-ops-transform-resize-in-edit-mode-using-pivot/560381 "2012-12-24T09:59:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![naturalpainter](https://blenderartists.org/user_avatar/blenderartists.org/naturalpainter/32/4115_2.png) [@naturalpainter](https://blenderartists.org/u/naturalpainter)\
**Post date:** [December 24, 2012, 9:59am UTC](https://blenderartists.org/t/how-to-bpy-ops-transform-resize-in-edit-mode-using-pivot/560381/1 "2012-12-24T09:59:08Z")

</div>

Hello:

On object mode, with the pivot center selected at the cursor, the object scales correctly, moving toward the cursor as reduced.

bpy.ops.transform.resize(value=(0.95, 0.95, 0.95))

In edit mode, it always is reduced against the median point of the selected faces even with the pivot at the cursor. How can I make it to behave like in object mode?

I need to use Edit mode because I just want to resize an extruded part of the object.

Thanks in advance for any help.

---

<div class="post-metadata">

**Author:** ![Shiprex](https://blenderartists.org/user_avatar/blenderartists.org/shiprex/32/32157_2.png) [@Shiprex](https://blenderartists.org/u/Shiprex)\
**Post date:** [November 1, 2014, 10:53am UTC](https://blenderartists.org/t/how-to-bpy-ops-transform-resize-in-edit-mode-using-pivot/560381/2 "2014-11-01T10:53:37Z")

</div>

The context override seems to work, applying the principles found here by Garrett:

> <https://blender.stackexchange.com/questions/6969/rotate-object-around-cursor-with-python>

you can get a resize from the pivot point in edit mode following:

1. Set active Viewport’s pivot to 3d cursor
2. Set up a context override function (copied from the link above, thanks!)

```auto
import bpy

def get_override(area_type, region_type):
    for area in bpy.context.screen.areas: 
        if area.type == area_type:             
            for region in area.regions:                 
                if region.type == region_type:                    
                    override = {'area': area, 'region': region} 
                    return override
    #error message if the area or region wasn't found
    raise RuntimeError("Wasn't able to find", region_type," in area ", area_type,
                        "
 Make sure it's open while executing script.")

#we need to override the context of our operator    
override = get_override( 'VIEW_3D', 'WINDOW' )

```

3.When applying transforms pass the override context as the first parameter

bpy.ops.transform.resize(override,value=(0.95, 0.95, 0.95))

Hope that helps!

---

<div class="post-metadata">

**Author:** ![Paraknight](https://blenderartists.org/user_avatar/blenderartists.org/paraknight/32/23716_2.png) [@Paraknight](https://blenderartists.org/u/Paraknight)\
**Post date:** [December 11, 2016, 3:27pm UTC](https://blenderartists.org/t/how-to-bpy-ops-transform-resize-in-edit-mode-using-pivot/560381/3 "2016-12-11T15:27:30Z")

</div>

Hope I don’t break any rules by necrobumping, but just wanted to thank you for this Shiprex! Been struggling with it for hours and your snippet solved all of my problems. Happy holidays!
