writeGCodeIntro(File)
Local tanAngle:Float = Tan(VAngle / 2)
Local i:Int = 0
For Local pfi:pathFiller = EachIn FillerList
'this will optimise the rapid moves between lines
If (i Mod 2 = 1) And OptimiseRapids Then
pfi.PointList.Reverse()
End If
For Local pp:pathPoint = EachIn pfi.PointList
Local ZDepth:Float = -(pp.Size * 0.5) / tanAngle
If (pp = PathPoint(pfi.PointList.First())) Then
WriteLine File, "G0 X" + (ZeroP.x + pp.Position.X) + " Y" + (ZeroP.y - pp.Position.Y) 'y coordinate must be inverted
WriteLine File, "G1 Z" + ZDepth + " F" + PlungeRate
WriteLine File, "F" + Feedrate
EndIf
WriteLine File, "X" + (ZeroP.x + pp.Position.X) + " Y" + (ZeroP.y - pp.Position.Y) + " Z" + ZDepth
Next
If (i Mod 2 = 1) And OptimiseRapids Then
pfi.PointList.Reverse()
End If
WriteLine File, "G0 Z" + SafeZ
i:+1
Next