Noobs question - apply matrix transform on edges ring

Hello,
I’m driving crazy with edges transformation …

Say that we have some cylinder like this one:

Say that we want to do multiple transformations (rotation, scaling, translation) on one ring like the selected one
Say also that we want to do some transformation on the next ring, apply some slightly different transformation on it and so on for all rings …

what’s the simplest way to that ?
Have we to find vertices of targeted edges and apply transformations on them ?
Could you please give some code as an example

Thank you so much !

Nobody ?
Is there a problem with this question? (unclear perhaps?)

Thank you very much for the slightest hint !

Transformations are usually handled with matrices. Create a Matrix() with the transform information you need. This should be a viable starting point for hints:
https://docs.blender.org/api/current/mathutils.html

Now you want to apply the matrix transformation to a vertex, you can do it like this:

matrix = mathutils.Matrix() # the transformation matrix
vertex_position = mathutils.Vector() # The vertex position you want to transform

transformed_vertex_position = matrix @ vertex_position # Apply the matrix transformation to the vertex position

Hi,

I succeeded but I wonder if there might be a way to simplify the code…

    name = "cylinder_transform"
    mesh_data = bpy.data.meshes.new(f"{name}_data")
    mesh_obj = bpy.data.objects.new(name, mesh_data)
    bpy.context.scene.collection.objects.link(mesh_obj)

    start_point = (1,0,0)
    steps = 32
    rotz = 360
    mat_rotz = Matrix.Rotation(radians(rotz)/steps, 4, 'Z')
    bm = bmesh.new()
    bm.from_mesh(mesh_obj.data)

    ori_vert = bm.verts.new(start_point)
    vertice = ori_vert
    for i in range(steps-1):
        extruded = bmesh.ops.extrude_vert_indiv(bm,verts=[vertice])
        translate_verts = [v for v in extruded['verts'] if isinstance(v, bmesh.types.BMVert)]
        bmesh.ops.transform(bm,matrix=mat_rotz, verts=translate_verts)
        bm.verts.ensure_lookup_table()
        vertice = bm.verts[-1]
    bm.edges.new((bm.verts[-1],bm.verts[0]))

    edges = bm.edges
    steps = 20
    tr_vec = Vector((0.1,0,1/steps))
    scl_vec = Vector((0.9, 0.9, 1))

    for i in range(steps):
        extruded = bmesh.ops.extrude_edge_only(bm, edges=edges)
        verts_extruded = [ele for ele in extruded["geom"]
        if isinstance(ele, bmesh.types.BMVert)]
        edges_extruded = [ele for ele in extruded["geom"]
        if isinstance(ele, bmesh.types.BMEdge)]
        bmesh.ops.translate(bm,vec=tr_vec,verts=verts_extruded)
        bmesh.ops.scale(bm, vec=scl_vec,verts=verts_extruded)
        edges = edges_extruded
    bm.to_mesh(mesh_obj.data)
    mesh_obj.data.update()
    bm.free()