chiark
/
gitweb
/
~ianmdlvl
/
cura.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
784821e
)
Speed up GCode loading a bit.
author
daid303
<daid303@gmail.com>
Wed, 13 Mar 2013 13:23:35 +0000
(14:23 +0100)
committer
daid303
<daid303@gmail.com>
Wed, 13 Mar 2013 13:23:35 +0000
(14:23 +0100)
Cura/util/gcodeInterpreter.py
patch
|
blob
|
history
diff --git
a/Cura/util/gcodeInterpreter.py
b/Cura/util/gcodeInterpreter.py
index eee6758b43295bc4854c8e16ed3c42a18be03aa3..a4a3de4d71b14822fe76ea8328d375aca3c28f26 100644
(file)
--- a/
Cura/util/gcodeInterpreter.py
+++ b/
Cura/util/gcodeInterpreter.py
@@
-4,6
+4,7
@@
import sys
import math
import re
import os
import math
import re
import os
+import time
from Cura.util import util3d
from Cura.util import profile
from Cura.util import util3d
from Cura.util import profile
@@
-65,7
+66,6
@@
class gcode(object):
feedRate = 3600
layerThickness = 0.1
pathType = 'CUSTOM';
feedRate = 3600
layerThickness = 0.1
pathType = 'CUSTOM';
- startCodeDone = False
currentLayer = []
currentPath = gcodePath('move', pathType, layerThickness, pos.copy())
currentPath.list[0].e = totalExtrusion
currentLayer = []
currentPath = gcodePath('move', pathType, layerThickness, pos.copy())
currentPath.list[0].e = totalExtrusion
@@
-78,9
+78,7
@@
class gcode(object):
#Parse Cura_SF comments
if line.startswith(';TYPE:'):
pathType = line[6:].strip()
#Parse Cura_SF comments
if line.startswith(';TYPE:'):
pathType = line[6:].strip()
- if pathType != "CUSTOM":
- startCodeDone = True
-
+
if ';' in line:
#Slic3r GCode comment parser
comment = line[line.find(';')+1:].strip()
if ';' in line:
#Slic3r GCode comment parser
comment = line[line.find(';')+1:].strip()
@@
-98,8
+96,6
@@
class gcode(object):
gcodeFile.close()
return
currentLayer = []
gcodeFile.close()
return
currentLayer = []
- if pathType != "CUSTOM":
- startCodeDone = True
line = line[0:line.find(';')]
T = self.getCodeInt(line, 'T')
if T is not None:
line = line[0:line.find(';')]
T = self.getCodeInt(line, 'T')
if T is not None:
@@
-271,28
+267,34
@@
class gcode(object):
#print "Estimated print duration: %.2f minutes" % (self.totalMoveTimeMinute)
def getCodeInt(self, line, code):
#print "Estimated print duration: %.2f minutes" % (self.totalMoveTimeMinute)
def getCodeInt(self, line, code):
- if code not in self.regMatch:
- self.regMatch[code] = re.compile(code + '([^\s]+)')
- m = self.regMatch[code].search(line)
- if m is None:
+ n = line.find(code) + 1
+ if n < 1:
return None
return None
+ m = line.find(' ', n)
try:
try:
- return int(m.group(1))
+ if m < 0:
+ return int(line[n:])
+ return int(line[n:m])
except:
return None
def getCodeFloat(self, line, code):
except:
return None
def getCodeFloat(self, line, code):
- if code not in self.regMatch:
- self.regMatch[code] = re.compile(code + '([^\s]+)')
- m = self.regMatch[code].search(line)
- if m is None:
+ n = line.find(code) + 1
+ if n < 1:
return None
return None
+ m = line.find(' ', n)
try:
try:
- return float(m.group(1))
+ if m < 0:
+ return float(line[n:])
+ return float(line[n:m])
except:
return None
if __name__ == '__main__':
except:
return None
if __name__ == '__main__':
+ t = time.time()
for filename in sys.argv[1:]:
for filename in sys.argv[1:]:
- gcode().load(filename)
+ g = gcode()
+ g.load(filename)
+ print g.totalMoveTimeMinute
+ print time.time() - t