Closed conifarad closed 11 months ago
I fixed it the same. Documentation is actually saying you should not use os.linesep when writing to files in text mode: https://docs.python.org/3/library/os.html#os.linesep
Great, thanks for noticing and fixing this!
The issue: When saving GCode on Windows (using
save_as
inGcodeControls
), FullControl puts unnecessary blank lines between commands.The cause: In the
gcode()
function, GCode lines are joined withos.linesep
, which on Windows is\r\n
. Python'swrite
function by default replaces\n
withos.linesep
, so\r\n
is written to the file as\r\r\n
. Text editors interpret this as two line breaks, so display a blank line. Since hardcoded multiline comments are already joined with\n
, these are translated correctly as\r\n
when written to a file.The solution: I changed
os.linesep
to'\n'
in thegcode()
functions. Now the GCode returned fromtransform
will consistently use\n
for line breaks, and the gcode written to the file will use the correct platform-dependent line breaks (\r\n
on Windows). I haven't tested the code for four-axis or five-axis, but I'm assuming it will work the same.Here are some sample before and after snippets:
Before
After