Skip to content

Commit

Permalink
Merge pull request #31 from avmaisak/dev
Browse files Browse the repository at this point in the history
Fixed PrusaSlicer Parser
  • Loading branch information
avmaisak authored Feb 13, 2020
2 parents 7363a06 + 95ca666 commit 10a1623
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 18 deletions.
6 changes: 3 additions & 3 deletions src/Gcode.Utils/Gcode.Utils.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<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.13</AssemblyVersion>
<AssemblyVersion>0.2.0.14</AssemblyVersion>
<PackageReleaseNotes></PackageReleaseNotes>
<Version>0.2.13</Version>
<FileVersion>0.2.0.13</FileVersion>
<Version>0.2.14</Version>
<FileVersion>0.2.0.14</FileVersion>
<PackageIconUrl>https://raw.githubusercontent.com/avmaisak/Gcode/master/misc/design/logo/logo.png</PackageIconUrl>
</PropertyGroup>

Expand Down
5 changes: 2 additions & 3 deletions src/Gcode.Utils/SlicerParser/PrusaSlicerParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@ public override Slic3RInfo GetSlicerInfo(string[] fileContent)
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(".", ","));
res.FilamentUsedExtruder1 = Convert.ToDecimal(filamentUsed[0].Split('=')[1].Split(',')[0].Trim().Replace(".",","));
}

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

var filamentDiameter = fileContent.FirstOrDefault(x => x.StartsWith("; filament_diameter"));
Expand Down
6 changes: 3 additions & 3 deletions tools/TestSuite/Gcode.Test/Gcode.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0-preview-20200102-01" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.0-beta2" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.0-beta2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.0" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
15 changes: 6 additions & 9 deletions tools/TestSuite/Gcode.Test/Infrastructure/TestSuiteDataSource.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.IO;

namespace Gcode.Test.Infrastructure {
namespace Gcode.Test.Infrastructure
{
public static class TestSuiteDataSource
{
private static readonly string InternalTestFolder = $@"{Directory.GetCurrentDirectory()}\..\..\..\..\..\TestData\";
Expand All @@ -15,15 +16,11 @@ public static class TestSuiteDataSource
"G1 X553.44 Y251.064 E0.01052 F2196",
"M115"
};

public static string GetDataSource(string fileName)
{
return File.ReadAllText($@"{InternalTestFolder}{fileName}");
}

public static string[] GetDataSourceArray(string fileName)
public static string GetDataSource(string fileName) => File.ReadAllText($@"{InternalTestFolder}{fileName}");
public static string[] GetDataSourceArray(string fileName, bool external = false)
{
return File.ReadAllLines($"{InternalTestFolder}{fileName}");
if (!external) return File.ReadAllLines($"{InternalTestFolder}{fileName}");
return File.ReadAllLines(fileName);
}
}
}

0 comments on commit 10a1623

Please sign in to comment.