Create a Scene in editor via script?

Hey,

I want to create a leveleditor for my 2D game to let others help me getting levels.
Now I thought about making a scene with all elements and save the positions a player is dragging the sprites to. Now I would like to create a scene out of the saved information.
But how can I write Code that is executed in the unity editor and not while playing?

take a look at this and this.