Create lines from points in layer separate by atribute with script

I am trying to create multiple trackplot lines from a file containing XY points and line names. All points are in the same file or layer. How can I use the create line from points function in the script and how can I split this on line name?