Script function that generates the stencil