You can’t convert sldprt file to G code. You have to use CAM program to program machining operations, and then need post processor to convert your tool paths into G-code. Post processors are machine control specific. If you are doing G code just for fun, not for production, then best way would be to use built in CAM in solidworks which is included with every license of Solidworks 2018 and 2019. If you need more help or guidance do not hesitate to ask.
Cheers!