Please look at one thing at the time.
The first step is simply to extract your mesh data (the set of entities, either lines, triangles or tetrahedrons)
def create_mesh(mesh, cell_type, prune_z=False):
cells = numpy.vstack([cell.data for cell in mesh.cells if cell.type==cell_type])
# Remove z-coordinates from mesh if we have a 2D cell and all points have the same third coordinate
points= mesh.points
if prune_z:
points = points[:,:2]
mesh_new = meshio.Mesh(points=points, cells={cell_type: cells})
return mesh_new
line_mesh = create_mesh(mesh_from_file, "line", prune_z=True)
meshio.write("facet_mesh.xdmf", line_mesh)
triangle_mesh = create_mesh(mesh_from_file, "triangle", prune_z=True)
meshio.write("mesh.xdmf", triangle_mesh)
If this works, it means that you have converted your mesh successfully.
If you have physical markers for your mesh, you should be able to inspect it by printing
print(mesh_from_file.cell_data_dict)
You then need to add the corresponding cell data to the mesh, as shown in the previous post.