Generating curve from tubular shape

You can try script written by Pascal