how to create new sketch plane

Hi,

I'm trying to speed up macro by drawing all the squares needed thenextruding it.
The entire design in a grid of cubes.

so I want to draw all the squares needed for a slice extruded them.then a 3d sketch plane to draw the 2nd slice.

I've been trying to achieve this by recording a macro but itreplays and the end result is something different.

Can someone please help me with the code to create a new 3d sketchplane that is referenced to the front plane and offset by adistance?

Thanks.SolidworksApi macros