Load segmentation and export surface mesh as model .ply

You can use slicer.util.loadSegmentation for loading a segmentation from file.

Note that in recent nightly versions of Slicer, you can export segmentation directly to stl or obj files. See Save segmentation directly to STL or OBJ files post for details and API documentation for description how it can be used from script.