-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from avmaisak/prusa-slicer
Added Prusa Slicer Parser
- Loading branch information
Showing
20 changed files
with
544,958 additions
and
15 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
src/Gcode.Utils/Entity/CuraSlicerInfo.cs → ...ode.Utils/Entity/Slicer/CuraSlicerInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Gcode.Utils/Entity/KisslicerInfo.cs → ...code.Utils/Entity/Slicer/KisslicerInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Gcode.Utils/Entity/Simplify3dInfo.cs → ...ode.Utils/Entity/Slicer/Simplify3dInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Gcode.Utils/Entity/Slic3RInfo.cs → src/Gcode.Utils/Entity/Slicer/Slic3RInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using System; | ||
using System.Linq; | ||
using Gcode.Utils.Entity.Slicer; | ||
|
||
namespace Gcode.Utils.SlicerParser | ||
{ | ||
public class PrusaSlicerParser: SlicerParserBase<Slic3RInfo> | ||
{ | ||
public override Slic3RInfo GetSlicerInfo(string[] fileContent) | ||
{ | ||
var name = fileContent.FirstOrDefault(x => x.StartsWith("; generated by PrusaSlicer ")); | ||
|
||
if (name?.Split(' ')[3] == null) return null; | ||
|
||
var res = new Slic3RInfo | ||
{ | ||
Name = name.Split(' ')[3], | ||
Version = name.Split(' ')[4], | ||
// no edition provided by Slic3r | ||
Edition = string.Empty, | ||
}; | ||
|
||
var filamentUsed = fileContent.Where(x => x.StartsWith("; filament used [mm] = ")).ToArray(); | ||
if (filamentUsed.Length == 1 && filamentUsed[0] != null) | ||
{ | ||
// filament used | ||
res.FilamentUsedExtruder1 = Convert.ToDecimal(filamentUsed[0].Split('=')[1]?.Split(' ')[1]?.Replace("[mm]", "").Replace(".", ",")); | ||
} | ||
|
||
if (filamentUsed.Length == 2 && filamentUsed[1] != null) | ||
{ | ||
// filament used | ||
res.FilamentUsedExtruder2 = Convert.ToDecimal(filamentUsed[1].Split('=')[1]?.Split(' ')[1]?.Replace("[mm]", "").Replace(".", ",")); | ||
} | ||
|
||
var filamentDiameter = fileContent.FirstOrDefault(x => x.StartsWith("; filament_diameter")); | ||
|
||
if (!string.IsNullOrWhiteSpace(filamentDiameter)) | ||
{ | ||
var diameter = filamentDiameter.Split('=')?[1]; | ||
if (string.IsNullOrWhiteSpace(diameter)) | ||
{ | ||
res.FilamentDiameter = null; | ||
} | ||
else | ||
{ | ||
if (diameter.Contains(",")) diameter = diameter.Split(',')[0]; | ||
res.FilamentDiameter = Convert.ToDecimal(diameter.Replace(".", ",")); | ||
} | ||
|
||
} | ||
|
||
if (res.FilamentUsedExtruder1 != null && res.FilamentUsedExtruder1 > 0 && res.FilamentDiameter != null && res.FilamentDiameter > 0) | ||
{ | ||
// обьем = сечение * длину | ||
res.FilamentUsedExtruder1Volume = res.FilamentDiameter * res.FilamentUsedExtruder1; | ||
} | ||
|
||
if (res.FilamentUsedExtruder2 != null && res.FilamentUsedExtruder2 > 0 && res.FilamentDiameter != null && res.FilamentDiameter > 0) | ||
{ | ||
// обьем = сечение * длину | ||
res.FilamentUsedExtruder2Volume = res.FilamentDiameter * res.FilamentUsedExtruder2; | ||
} | ||
|
||
return res; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.