# How to scale several points with one inner point using python script?

I have several points' coordinate that constructed one polygon. I want to scale this polygon with a point inside the polygon and get points' coordinates after scaling.

– X Y
May 19 at 11:54
• @XY op is asking for how to do this via python, also asking how to get vert locs after the transform. May 19 at 12:02
• Not sure if the asker knows the coordinates of the geometric center.
– X Y
May 19 at 12:25
• @XY Yes the center coordinates is prepared. May 19 at 12:42
– X Y
May 19 at 12:50

Something like this should work.

import pprint as pp
import bpy
import bmesh
from mathutils import Vector

# object needs to be in edit mode for this exact
# technique to work. There are other ways to
# one of the quicker ways.

obj = bpy.context.active_object
mesh = obj.data
bm = bmesh.from_edit_mesh(mesh)

# vector to scale the verts by
scale_amt = Vector((2,2,0))

vert_locs_current = [v.co for v in bm.verts]
pp.pprint(vert_locs_current)

#[Vector((-5.449918746948242, -3.937771797180176, 0.0)),
# Vector((2.550081729888916, -2.3869245052337646, 0.0)),
# Vector((-5.449918746948242, 4.062228202819824, 0.0)),
# Vector((2.550081729888916, 2.511380434036255, 0.0)),
# Vector((-8.69951057434082, 0.3733687400817871, 0.0))]

# loop through the vertices
for v in bm.verts:
# scaling them uniformly is the same as just
# multiplying their current coordinates by a Vector
v.co *= scale_amt

# this is so the new vert locations can be seen in
# the viewport
bmesh.update_edit_mesh(mesh)

vert_locs_new = [v.co for v in bm.verts]
pp.pprint(vert_locs_new)

#[Vector((0.16568545997142792, 1.999999761581421, 0.0)),
# Vector((-1.8343143463134766, -1.827902167406137e-07, 0.0)),
# Vector((0.16568563878536224, -2.0, 0.0)),
# Vector((1.5798989534378052, -1.41421377658844, 0.0)),
# Vector((1.5798993110656738, 1.4142131805419922, 0.0))]
$$$$

• This is the before and after of my script overlaid over eachother, I think it's something to do with you script that's not related. Are you sure you're using *= and not *+= anywhere you're manipulating coordinates? May 19 at 13:02
• Note that this script requires the object to be in edit mode. May 19 at 18:26