Convert primitive collection to entity collection

hello, I have finished the drawing function in my project by primitive,but now I need to export it to a KML file by the named ‘exportKML’ function.But this function just only recetp EntityCollection.