mirror of
https://github.com/riegera2412/UVtools.git
synced 2026-07-11 02:52:35 +02:00
v2.14.2
- **Exposure time finder:** - (Add) [ME] Option: 'Use different settings for layers with same Z positioning' - (Add) [ME] Option: 'Lift height' for same Z positioned layers - (Add) [ME] Option: 'Light-off delay' for same Z positioned layers - (Improvement) Auto-detect and optimize the 'multiple exposures' test to decrease the print time, by set a minimal lift to almost none - (Improvement) Better information on the thumbnail - (Fix) Importing a profile would crash the application - (Fix) Error with 'Pattern loaded model' fails when generating more models than build plate can afford (#239) - **GCode:** - (Fix) When the last layer have no lifts and a move to top command is set on end, that value were being set incorrectly as last layer position - (Fix) Layer parsing from mm/s to mm/m bad convertion - (Add) File formats: Setter `SuppressRebuildGCode` to disable or enable the gcode auto rebuild when needed, set this to false to manually write your own gcode - (Fix) ZCode: Some test files come with layer height of 0mm on a property, in that case lookup layer height on the second property as fallback
This commit is contained in:
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* Version 3, 19 November 2007
|
||||
* Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
* Everyone is permitted to copy and distribute verbatim copies
|
||||
* of this license document, but changing it is not allowed.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using UVtools.Core.Scripting;
|
||||
using System.IO;
|
||||
using UVtools.Core;
|
||||
using UVtools.Core.Extensions;
|
||||
using UVtools.Core.FileFormats;
|
||||
|
||||
namespace UVtools.ScriptSample
|
||||
{
|
||||
/// <summary>
|
||||
/// Change layer properties to random values
|
||||
/// </summary>
|
||||
public class ScriptCustomGCode : ScriptGlobals
|
||||
{
|
||||
/// <summary>
|
||||
/// Set configurations here, this function trigger just after load a script
|
||||
/// </summary>
|
||||
public void ScriptInit()
|
||||
{
|
||||
Script.Name = "Custo gcode generator";
|
||||
Script.Description = "Generates custom gcode and saves the file";
|
||||
Script.Author = "Tiago Conceição";
|
||||
Script.Version = new Version(0, 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate user inputs here, this function trigger when user click on execute
|
||||
/// </summary>
|
||||
/// <returns>A error message, empty or null if validation passes.</returns>
|
||||
public string ScriptValidate()
|
||||
{
|
||||
return SlicerFile.SupportsGCode ? null : "GCode is not supported on this file";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Execute the script, this function trigger when when user click on execute and validation passes
|
||||
/// </summary>
|
||||
/// <returns>True if executes successfully to the end, otherwise false.</returns>
|
||||
public bool ScriptExecute()
|
||||
{
|
||||
var gcode = SlicerFile.GCode;
|
||||
gcode.Clear();
|
||||
|
||||
float pos = 1;
|
||||
float layerHeight = 0.025f;
|
||||
float liftHeight = 4.5f;
|
||||
float feedrate = gcode.ConvertFromMillimetersPerMinute(150);
|
||||
float lightoff = gcode.ConvertFromSeconds(1f);
|
||||
|
||||
gcode.AppendStartGCode();
|
||||
//gcode.AppendShowImageM6054(gcode.GetShowImageString(0));
|
||||
//gcode.AppendWaitG4(gcode.ConvertFromSeconds(2));
|
||||
//gcode.AppendTurnLightM106(255);
|
||||
gcode.AppendWaitG4(gcode.ConvertFromSeconds(1));
|
||||
//gcode.AppendTurnLightM106(0);
|
||||
gcode.AppendLiftMoveG0(20, feedrate, pos, feedrate);
|
||||
gcode.AppendWaitG4(gcode.ConvertFromSeconds(5));
|
||||
|
||||
// 0.025 test
|
||||
/*gcode.AppendComment("0.025 layer height simulated print test");
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
pos = Layer.RoundHeight(pos + layerHeight);
|
||||
var liftPos = Layer.RoundHeight(pos + liftHeight);
|
||||
gcode.AppendLiftMoveG0(liftPos, feedrate, pos, feedrate, lightoff);
|
||||
}*/
|
||||
|
||||
// 0.01 test
|
||||
gcode.AppendComment("0.01 layer height simulated print test");
|
||||
pos = 1;
|
||||
layerHeight = 0.01f;
|
||||
|
||||
|
||||
gcode.AppendMoveG0(pos, feedrate);
|
||||
gcode.AppendWaitG4(gcode.ConvertFromSeconds(5));
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
pos = Layer.RoundHeight(pos + layerHeight);
|
||||
var liftPos = Layer.RoundHeight(pos + liftHeight);
|
||||
gcode.AppendLiftMoveG0(liftPos, feedrate, pos, feedrate, lightoff);
|
||||
}
|
||||
|
||||
// 0.001 test
|
||||
/*gcode.AppendComment("0.001 layer height simulated print test");
|
||||
pos = 1;
|
||||
layerHeight = 0.001f;
|
||||
liftHeight = 1;
|
||||
|
||||
gcode.AppendMoveG0(pos, feedrate);
|
||||
gcode.AppendWaitG4(gcode.ConvertFromSeconds(5));
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
pos = Layer.RoundHeight(pos + layerHeight);
|
||||
var liftPos = Layer.RoundHeight(pos + liftHeight);
|
||||
gcode.AppendLiftMoveG0(liftPos, feedrate, pos, feedrate, lightoff);
|
||||
}*/
|
||||
|
||||
|
||||
/*// 0.05 backlash test
|
||||
gcode.AppendComment("0.05 backlash test");
|
||||
pos = 1;
|
||||
layerHeight = 0.02f;
|
||||
|
||||
gcode.AppendMoveG0(pos, feedrate);
|
||||
//gcode.AppendWaitG4(gcode.ConvertFromSeconds(5));
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
var liftPos = Layer.RoundHeight(pos + layerHeight);
|
||||
gcode.AppendMoveG0(liftPos, feedrate);
|
||||
gcode.AppendWaitG4(lightoff);
|
||||
gcode.AppendMoveG0(pos, feedrate);
|
||||
gcode.AppendWaitG4(lightoff);
|
||||
}
|
||||
*/
|
||||
|
||||
/*gcode.AppendMoveG0(2, gcode.ConvertFromMillimetersPerMinute(150));
|
||||
gcode.AppendWaitG4(lightoff);
|
||||
gcode.AppendMoveG0(2.5f, gcode.ConvertFromMillimetersPerMinute(160));
|
||||
gcode.AppendWaitG4(lightoff);
|
||||
gcode.AppendMoveG0(3f, gcode.ConvertFromMillimetersPerMinute(170));
|
||||
gcode.AppendWaitG4(lightoff);
|
||||
gcode.AppendMoveG0(3.5f, gcode.ConvertFromMillimetersPerMinute(180));
|
||||
gcode.AppendWaitG4(lightoff);
|
||||
gcode.AppendMoveG0(4.0f, gcode.ConvertFromMillimetersPerMinute(190));
|
||||
gcode.AppendWaitG4(lightoff);
|
||||
gcode.AppendMoveG0(4.5f, gcode.ConvertFromMillimetersPerMinute(195));
|
||||
gcode.AppendWaitG4(lightoff);
|
||||
gcode.AppendMoveG0(5f, gcode.ConvertFromMillimetersPerMinute(199));
|
||||
gcode.AppendWaitG4(lightoff);
|
||||
gcode.AppendMoveG0(5.5f, gcode.ConvertFromMillimetersPerMinute(205));
|
||||
gcode.AppendWaitG4(lightoff);*/
|
||||
|
||||
gcode.AppendMoveG0(100, feedrate);
|
||||
//gcode.AppendTurnMotors(false);
|
||||
|
||||
|
||||
|
||||
SlicerFile.SuppressRebuildGCode = true;
|
||||
SlicerFile.Save(Progress);
|
||||
SlicerFile.SuppressRebuildGCode = false;
|
||||
|
||||
// return true if not cancelled by user
|
||||
return !Progress.Token.IsCancellationRequested;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user