I m trying to generate g codes from solid model..I dont have any idea how difficult it is..can anyone help?

I have decided to follow following steps -

1.Generate ASCII STL model in solidworks (done.)

2. import it in MATLAB and plot it (done)

3.Use slicing algorithm and get contour info (in MATLAB only)

4. get G code (No idea how am i gonna do this)