Skip to content

Commit

Permalink
* Fix PrusaSlicer v2alpha4 with multiple extruders
Browse files Browse the repository at this point in the history
* Updated Test Suite Manual Execution
* Added Test Gcode File For PrusaSlicer v2alpha4
  • Loading branch information
Anton Maisak authored and Anton Maisak committed Feb 14, 2020
1 parent badd2a1 commit 95874ea
Show file tree
Hide file tree
Showing 6 changed files with 61,594 additions and 23 deletions.
20 changes: 15 additions & 5 deletions src/Gcode.Utils/Gcode.Utils.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@
<Description>Утилиты для работы с файлами формата G-code для платформы .NET</Description>
<Authors>Anton Maisak</Authors>
<Company>Anton Maisak</Company>
<PackageLicenseUrl>https://github.com/avmaisak/Gcode/blob/master/LICENSE</PackageLicenseUrl>
<PackageLicenseUrl></PackageLicenseUrl>
<PackageProjectUrl>https://github.com/avmaisak/Gcode</PackageProjectUrl>
<RepositoryUrl>https://github.com/avmaisak/Gcode.git</RepositoryUrl>
<PackageTags>gcode 3d-printing reprap reprap-3d-printer marlin marlin-firmware repitier repitier-firmware json json-parsing gcode-json cura kisslicer slic3r simplify3d</PackageTags>
<RepositoryType>git</RepositoryType>
<Copyright>Anton Maisak</Copyright>
<AssemblyVersion>0.2.0.15</AssemblyVersion>
<AssemblyVersion>0.2.0.16</AssemblyVersion>
<PackageReleaseNotes></PackageReleaseNotes>
<Version>0.2.15</Version>
<FileVersion>0.2.0.15</FileVersion>
<PackageIconUrl>https://raw.githubusercontent.com/avmaisak/Gcode/master/misc/design/logo/logo.png</PackageIconUrl>
<Version>0.2.16</Version>
<FileVersion>0.2.0.16</FileVersion>
<PackageIconUrl></PackageIconUrl>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageIcon>logo.png</PackageIcon>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand All @@ -32,6 +34,14 @@
<Compile Remove="SlicerParser\Base\**" />
<EmbeddedResource Remove="SlicerParser\Base\**" />
<None Remove="SlicerParser\Base\**" />
<None Include="..\..\LICENSE">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
<None Include="..\..\misc\design\logo\logo.png">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
</ItemGroup>

<ItemGroup>
Expand Down
36 changes: 28 additions & 8 deletions src/Gcode.Utils/SlicerParser/PrusaSlicerParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Gcode.Utils.SlicerParser
{
public class PrusaSlicerParser: SlicerParserBase<Slic3RInfo>
public class PrusaSlicerParser : SlicerParserBase<Slic3RInfo>
{
public override Slic3RInfo GetSlicerInfo(string[] fileContent)
{
Expand All @@ -23,15 +23,35 @@ public override Slic3RInfo GetSlicerInfo(string[] fileContent)
var filamentUsed = fileContent.Where(x => x.StartsWith("; filament used [mm] = ")).ToArray();
if (filamentUsed.Length == 1 && filamentUsed[0] != null)
{
res.FilamentUsedExtruder1 = Convert.ToDecimal(filamentUsed[0].Split(';')[1].Split('=')[1].Trim().Replace(".",","));
}
var result = filamentUsed[0].Split(';')[1].Split('=')[1].Trim().Replace(".", ",");
// two extruders
if (result.Contains(" "))
{
var resultArray = result.Split(' ');
if (resultArray.Length == 2)
{
var filamentUsedExtruder1 = resultArray[0].Trim().Replace(".", ",");
var filamentUsedExtruder2 = resultArray[1].Trim().Replace(".", ",");

if (filamentUsed.Length == 2 && filamentUsed[1] != null)
{
// filament used
res.FilamentUsedExtruder2 = Convert.ToDecimal(filamentUsed[1].Split(';')[1].Split('=')[1].Trim().Replace(".",","));
if (filamentUsedExtruder1.EndsWith(",")) filamentUsedExtruder1 = filamentUsedExtruder1.Remove(filamentUsedExtruder1.Length - 1);

res.FilamentUsedExtruder1 = Convert.ToDecimal(filamentUsedExtruder1);
res.FilamentUsedExtruder2 = Convert.ToDecimal(filamentUsedExtruder2);
}
// res.FilamentUsedExtruder2 = Convert.ToDecimal(filamentUsed[1].Split(';')[1].Split('=')[1].Trim().Replace(".",","));
}
else
{
res.FilamentUsedExtruder1 = Convert.ToDecimal(result);
}
}

//if (filamentUsed.Length == 2 && filamentUsed[1] != null)
//{
// // filament used
// res.FilamentUsedExtruder2 = Convert.ToDecimal(filamentUsed[1].Split(';')[1].Split('=')[1].Trim().Replace(".",","));
//}

var filamentDiameter = fileContent.FirstOrDefault(x => x.StartsWith("; filament_diameter"));

if (!string.IsNullOrWhiteSpace(filamentDiameter))
Expand All @@ -46,7 +66,7 @@ public override Slic3RInfo GetSlicerInfo(string[] fileContent)
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)
Expand Down
Loading

0 comments on commit 95874ea

Please sign in to comment.