There is a Script repository that contains hundreds of little code examples, including this: Script repository — 3D Slicer documentation
Btw I just posted a piece of code in another thread that among other things gets the position of a control point. You could use it as inspiration. Here it is: Exporting a model to STL with markups - #2 by cpinter