Using python to scale/resize a selected groups of faces with individual origin question based on this topic Using python and bmesh to scale/resize a face in place where each face was scaled separately.
So actually the question in the title. I'm newbie to python. I tried to find connected faces based on the same vertex indexes, then calculate the average mean of the vertices positions included this faces(like a origin point).
But it works only for single group faces, how to make it for multiple group faces?


import bpy
import bmesh
import numpy as np
from mathutils import Vector as vec

#EDIT mode#
me = bpy.context.edit_object.data
bm = bmesh.from_edit_mesh(me)
scale_factor = 0.5

seleted_vert_group = []
verts_co_x = []
verts_co_y = []
verts_co_z = []

#checking for matches
for face1 in bm.select_history:
    passwither = 0 #pass double matched face
    for face2 in bm.select_history:
        if face1 == face2:
            continue
        for vert1 in face1.verts: 
            for vert2 in face2.verts:
                if passwither == 1:
                    continue
                if vert1.index == vert2.index:
                    passwither = 1
                    print(f'face index: {face1.index}')
                    for vert in face1.verts:
                        seleted_vert_group.append(vert)
                        verts_co_x.append(vert.co.x)
                        verts_co_y.append(vert.co.y)
                        verts_co_z.append(vert.co.z)

co_x = np.sum(verts_co_x)/len(verts_co_x)
co_y = np.sum(verts_co_y)/len(verts_co_y)
co_z = np.sum(verts_co_z)/len(verts_co_z)
origin_point = vec((co_x,co_y,co_z))
 
for vert in set(seleted_vert_group):
    vert.co = origin_point + scale_factor * (vert.co - origin_point)

bmesh.update_edit_mesh(me)
Hi you should move back them into first position.
I answered based on this question

import bpy
import bmesh

context = bpy.context


ob = context.edit_object
me = ob.data
bm = bmesh.from_edit_mesh(me)
scale_factor = 0.5

for face in bm.select_history:
        center = face.calc_center_median()
        for v in face.verts:
            v.co = center + scale_factor * (v.co - center)

bmesh.update_edit_mesh(me)