Files
create/src/Mod/Path/PathScripts/nc/num_reader.py
sliptonic b67f6f1886 Extensive Path Workbench improvements.
Implement libarea improvements for profile
Implement libarea pocketing.
consolidate occ and libarea pocketing operation into one with algorithm
switch
consolidate occ aand libarea profile op into one with algorithm switch
add basic engraving operation.
Add rough UI for profile holding tags
implement holding tags for libarea profile.
implement basic defaults for depth settings.
First move in Drilling is rapid to clearance height.

UI needs lots of work but is usable.
2016-05-23 13:04:58 -03:00

64 lines
1.8 KiB
Python

import nc_read as nc
import sys
import math
# a base class for hpgl parsers, and maybe others
class NumReader(nc.Parser):
def __init__(self, writer):
nc.Parser.__init__(self, writer)
def get_number(self):
number = ''
# skip spaces and commas at start of number
while(self.line_index < self.line_length):
c = self.line[self.line_index]
if c == ' ' or c == ',':
self.parse_word += c
else:
break
self.line_index = self.line_index + 1
while(self.line_index < self.line_length):
c = self.line[self.line_index]
if c == '.' or c == '0' or c == '1' or c == '2' or c == '3' or c == '4' or c == '5' or c == '6' or c == '7' or c == '8' or c == '9' or c == '-':
number += c
else:
break
self.parse_word += c
self.line_index = self.line_index + 1
return number
def add_word(self, color):
self.writer.add_text(self.parse_word, color, None)
self.parse_word = ""
def Parse(self, name):
self.file_in = open(name, 'r')
while self.readline():
self.writer.begin_ncblock()
self.parse_word = ""
self.line_index = 0
self.line_length = len(self.line)
while self.line_index < self.line_length:
c = self.line[self.line_index]
self.parse_word += c
self.ParseFromFirstLetter(c)
self.line_index = self.line_index + 1
self.writer.add_text(self.parse_word, None, None)
self.writer.end_ncblock()
self.file_in.close()