bpy mesh to kx mesh

Hi all, I am new to this forum and i hope to find some help for my current project here.

I wrote a python script that replaces the mesh of an object with a mesh created by “mesh.from_pydata(vertexlist, [], polylist)”

It works all fine when i start the script in object mode but when i start it in game engine mode i get the error massage:

TypeError: gameOb.replace.Mesh(value): KX_GameObject, expect a KX_MeshProxy or a string

I printed the tyee of the replacement mesh with “print(type(ob_new.data))” and the type is “class ‘bpy_types.Mesh’”.
Is it possible to convert the bpy_mesh to a kx_meshproxy or to create a kx_meshproxi from a vertex and a polylist?