-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommandChangeGcode.py
More file actions
45 lines (29 loc) · 1.15 KB
/
commandChangeGcode.py
File metadata and controls
45 lines (29 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
""" NOTE FOR EVALUATING RESULTS:
The sample will print from RIGHT to LEFT (from the viewer's standpoint)
That means the lower end of the range will be on the RIGHT
Be sure to label the sample BEFORE removing it from the build plate to ensure the directions don't get mixed up
"""
from util import getAllFileLines, writeFileLines, FileLines
NEW_FILE_PREFIX = "temp"
START_RANGE = 190
END_RANGE = 250
NUM_STEPS = 10
COMMAND = "M104 S<VAR>\n"
fileLines: FileLines = getAllFileLines()
stepSize = len(fileLines.drawLines)//NUM_STEPS
outputLines = fileLines.startLines
totalRange = END_RANGE - START_RANGE
lastIndex = 0
# We stop a step before the actual end to give the last value time to appear
lastValue = len(fileLines.drawLines) - stepSize
for i in range(0, lastValue, stepSize):
outputLines += fileLines.drawLines[lastIndex:i]
lastIndex = i
ratio = i/lastValue
currentValue = int(totalRange * ratio)
print(currentValue)
actualValue = START_RANGE + currentValue
outputLines.append(COMMAND.replace("<VAR>", str(actualValue)))
outputLines += fileLines.drawLines[lastIndex:]
outputLines += fileLines.endLines
writeFileLines(outputLines, NEW_FILE_PREFIX)