Example #1
0
 public string ToGCode(ExportFileOptions options)
 {
     using (var ms = new MemoryStream())
     {
         ToStream(ms, options);
         ms.Position = 0;
         return(new StreamReader(ms).ReadToEnd());
     }
 }
Example #2
0
        public void ToStream(Stream stream, ExportFileOptions options)
        {
            var writer = new StreamWriter(stream);

            var commands = this.Commands.ToArray();

            if (options.WriteLineNumbers)
            {
                int lineCounter = 1;
                commands = RemoveAllLineNumbers(commands);
                foreach (var command in commands)
                {
                    writer.WriteLine(command.ToGCode(options.WriteCRC, lineCounter++));
                }
            }
            else
            {
                foreach (var command in commands)
                {
                    writer.WriteLine(command.ToGCode(options.WriteCRC));
                }
            }
            writer.Flush();
        }