Making layer height get calculated better for non-matterslice files
issue: MatterHackers/MatterControl#4494 Gcode read problem/crash
This commit is contained in:
parent
a687a0c647
commit
3545043079
2 changed files with 26 additions and 4 deletions
|
|
@ -294,12 +294,34 @@ namespace MatterControl.Printing
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (IndexOfLayerStart.Count > 2)
|
||||
// set it to a number that might be reasonable
|
||||
var layerHeight = .2;
|
||||
if (IndexOfLayerStart.Count > layerIndex + 1)
|
||||
{
|
||||
return GCodeCommandQueue[IndexOfLayerStart[2]].Z - GCodeCommandQueue[IndexOfLayerStart[1]].Z;
|
||||
layerHeight = GCodeCommandQueue[IndexOfLayerStart[layerIndex + 1]].Z - GCodeCommandQueue[IndexOfLayerStart[layerIndex]].Z;
|
||||
}
|
||||
else if (IndexOfLayerStart.Count > 2)
|
||||
{
|
||||
layerHeight = GCodeCommandQueue[IndexOfLayerStart[2]].Z - GCodeCommandQueue[IndexOfLayerStart[1]].Z;
|
||||
}
|
||||
|
||||
return .5;
|
||||
if (layerHeight < .01)
|
||||
{
|
||||
layerIndex--;
|
||||
while (layerIndex >= 0
|
||||
&& layerHeight < .01)
|
||||
{
|
||||
// walk back to find a layer height that seems like it might be right
|
||||
if (layerHeight < IndexOfLayerStart.Count - 2)
|
||||
{
|
||||
layerHeight = GCodeCommandQueue[IndexOfLayerStart[layerIndex + 1]].Z - GCodeCommandQueue[IndexOfLayerStart[layerIndex]].Z;
|
||||
}
|
||||
|
||||
layerIndex--;
|
||||
}
|
||||
}
|
||||
|
||||
return layerHeight;
|
||||
}
|
||||
|
||||
public override int GetLayerIndex(int instructionIndex)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue