Why would you want to do that? You know that the origin is no special object or part of the model floating around, but simply the spot where x=y=z=0, right? That means if you want to change the "origin" by script, you will need to move every vertex of the model.
"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual