Skip to content

Commit

Permalink
Added Simplify3dParser
Browse files Browse the repository at this point in the history
Packages Updates
  • Loading branch information
avmaisak committed May 7, 2019
1 parent 10025bc commit 33dc9ef
Show file tree
Hide file tree
Showing 7 changed files with 277,653 additions and 5 deletions.
9 changes: 9 additions & 0 deletions src/Gcode.Utils/Entity/Simplify3dInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Gcode.Utils.Entity
{
/// <summary>
/// Simplify3D(R) info.
/// </summary>
public class Simplify3dInfo : SlicerInfo
{
}
}
4 changes: 2 additions & 2 deletions src/Gcode.Utils/Gcode.Utils.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<AssemblyVersion>0.2.0.7</AssemblyVersion>
<PackageReleaseNotes>Gcode.Entity
Gcode.Common.Utils</PackageReleaseNotes>
<Version>0.2.7</Version>
<Version>0.2.8</Version>
<FileVersion>0.2.0.7</FileVersion>
<PackageIconUrl>https://raw.githubusercontent.com/avmaisak/Gcode/master/misc/design/logo/logo.png</PackageIconUrl>
</PropertyGroup>
Expand All @@ -30,7 +30,7 @@ Gcode.Common.Utils</PackageReleaseNotes>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="LibBase" Version="1.0.3" />
<PackageReference Include="LibBase" Version="1.0.4" />
</ItemGroup>

</Project>
5 changes: 5 additions & 0 deletions src/Gcode.Utils/SlicerParser/KisSlicerParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public override KisSlicerInfo GetSlicerInfo(string[] fileContent)
Edition = name.Split(';')[1]?.Split('-')[1]?.Trim() ?? string.Empty,
};

if (string.IsNullOrWhiteSpace(res.Name))
{
return null;
}

var buildTimeStr = fileContent.FirstOrDefault(x => x.StartsWith("; Estimated Build Time:"));
if (buildTimeStr != null)
{
Expand Down
73 changes: 73 additions & 0 deletions src/Gcode.Utils/SlicerParser/Simplify3dParser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using System;
using System.Linq;
using Gcode.Utils.Entity;

namespace Gcode.Utils.SlicerParser
{
/// <summary>
/// Simplify3D
/// </summary>
public class Simplify3dParser : SlicerParserBase<Simplify3dInfo>
{
public override Simplify3dInfo GetSlicerInfo(string[] fileContent)
{
var name = fileContent[0];
if (name == null || !name.Contains("Simplify3D"))
{
return null;
}

var res = new Simplify3dInfo
{
Name = name.Split(new[] { "Version" }, StringSplitOptions.RemoveEmptyEntries)[0]?.Split(' ')[4]?.Replace("(R)", string.Empty) ?? string.Empty,
Version = name.Split(new[] { "Version" }, StringSplitOptions.RemoveEmptyEntries)[1].Trim(),
// Simplify3D does not provide edition
Edition = null,
};

if (string.IsNullOrWhiteSpace(res.Name))
{
return null;
}

var buildTime = fileContent.FirstOrDefault(x => x.Contains("Build time:"));
if (!string.IsNullOrWhiteSpace(buildTime))
{
var hours = 0;
var minutes = 0;
// hours
if (buildTime.Contains("hour"))
{
hours = Convert.ToInt32(buildTime.Split(new[] { "hours" }, StringSplitOptions.RemoveEmptyEntries)?[0]?.Split(' ')?[5] ?? "0");
}

if (buildTime.Contains("minute"))
{
minutes = Convert.ToInt32(buildTime.Split(new[] { "minutes" }, StringSplitOptions.RemoveEmptyEntries)?[0]?.Split(' ')?[7] ?? "0");
}

res.EstimatedBuildTime = Convert.ToDecimal(hours) * (decimal) 60.00 + Convert.ToDecimal(minutes);
}

var buildCostStr = fileContent.FirstOrDefault(x => x.Contains("Material cost:"));
if (!string.IsNullOrWhiteSpace(buildCostStr))
{
res.EstimatedBuildCost = Convert.ToDecimal(buildCostStr.Split(' ')?[5]?.Replace(".",",") ?? "0" );
}

var filamentUsage = fileContent.FirstOrDefault(x => x.Contains("Filament length:"));
if (!string.IsNullOrWhiteSpace(filamentUsage))
{
res.FilamentUsedExtruder1 = Convert.ToDecimal(filamentUsage.Split(' ')?[5]?.Replace(".",",") ?? "0");
}

var volume = fileContent.FirstOrDefault(x => x.Contains("Plastic volume:"));
if (!string.IsNullOrWhiteSpace(volume))
{
res.FilamentUsedExtruder1Volume = Convert.ToDecimal(volume.Split(' ')?[5]?.Replace(".",",") ?? "0");
}

return res;
}
}
}
Loading

0 comments on commit 33dc9ef

Please sign in to comment.