-
Notifications
You must be signed in to change notification settings - Fork 1
/
absToRel.py
44 lines (31 loc) · 1.81 KB
/
absToRel.py
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
#/usr/bin/python
string = "PU385,800;PD410,804;PD431,816;PD447,833;PD457,856;PD544,856;PD617,688;PD624,680;PD635,677;PD645,681;PD651,689;PD743,952;PD857,688;PD864,680;PD874,677;PD884,681;PD891,689;PD982,952;PD1097,688;PD1104,680;PD1114,677;PD1124,681;PD1130,689;PD1222,952;PD1280,814;PD1287,806;PD1297,803;PD1397,803;PD1407,781;PD1423,763;PD1444,752;PD1468,748;PD1497,753;PD1521,769;PD1536,793;PD1542,821;PD1536,850;PD1521,873;PD1497,889;PD1468,895;PD1444,891;PD1423,879;PD1407,862;PD1397,839;PD1309,839;PD1237,1009;PD1230,1017;PD1220,1020;PD1210,1016;PD1203,1008;PD1111,745;PD997,1009;PD990,1017;PD980,1020;PD970,1016;PD963,1008;PD872,745;PD757,1009;PD750,1017;PD740,1020;PD730,1016;PD724,1008;PD632,745;PD572,881;PD566,889;PD556,892;PD457,892;PD447,914;PD431,931;PD410,943;PD385,947;PD356,942;PD333,926;PD317,902;PD311,874;PD317,845;PD333,822;PD356,806;PD385,800;PD385,800;PU1468,859;PD1483,856;PD1495,848;PD1503,836;PD1506,821;PD1503,807;PD1495,795;PD1483,787;PD1468,784;PD1454,787;PD1442,795;PD1434,807;PD1431,821;PD1434,836;PD1442,848;PD1454,856;PD1468,859;PD1468,859;PU385,911;PD400,908;PD412,900;PD420,888;PD423,874;PD420,859;PD412,847;PD400,839;PD385,836;PD370,839;PD359,847;PD350,859;PD347,874;PD350,888;PD359,900;PD370,908;PD385,911;PD385,911;PU;"
cmds = string.split(";")
print cmds
fixedCmds = ""
curX = 0
curY = 0
prevX = 0;
prevY = 0;
firstCmd = True;
newCommands = ""
for cmd in cmds:
oldCmd = cmd[:2]
try:
cmdSplit = cmd.split(",")
curX = cmdSplit[0][2:]
curY = cmdSplit[1]
except:
break
print oldCmd + " : " + curX + ":" + curY
relX = int(curX) - int(prevX);
relY = int(curY) - int(prevY);
if oldCmd == "PD":
newCmd = "PR%s,%s"%(relX, relY)
if oldCmd == "PU":
newCmd = "PU;PR%s,%s;PD;"%(relX, relY)
print "\t" + newCmd
prevX = curX;
prevY = curY;
newCommands += newCmd + ";"
print newCommands