Home/ Reference/ Geometry & Transform

shape.SetSize(w, h, anchor)

Scales; the default anchor is top-left. Proportional scaling is on you: s = max(W/ow, H/oh); img.SetSize(ow*s, oh*s).

Signature

shape.SetSize(w, h, anchor)

Notes

Scales; the default anchor is top-left. Proportional scaling is on you: s = max(W/ow, H/oh); img.SetSize(ow*s, oh*s).

Python example (runnable)

Requires pywin32. The example assumes app / doc / page / layer are already connected. See Connection & Init
Python
shape = app.ActiveSelectionRange(1)

# proportional fit: use the larger of the two ratios so it fills without distortion
BOX_W, BOX_H = 100 / 25.4, 60 / 25.4       # target box, in document units
scale = max(BOX_W / shape.SizeWidth, BOX_H / shape.SizeHeight)

shape.SetSize(shape.SizeWidth * scale, shape.SizeHeight * scale)
print("Scale factor: ", round(scale, 3))

About this section: Geometry & Transform

Geometry & Transform — position, size and rotation of shapes.

Other entries in this section