def save_to_txt(self, fp, name): g = Gcode(name, self).to_string_list() with open(fp + name + '.txt', 'w') as f: for line in g: f.write("%s\n" % line) return None
def __init__(self, jsonName, outputFileName, gRobot, layerParamLabels, partParamLabels): self.outputFileName = outputFileName with open(jsonName, 'r') as fp: data = json.load(fp) self.pr = makeParamObj(data[0], data[1], layerParamLabels, partParamLabels) if gRobot == c.GCODE: self.gc = Gcode(self.pr) elif gRobot == c.ROBOTCODE: self.gc = RobotCode(self.pr)
from crease import Crease from patternLoader import PatternLoader from gcode import Gcode from pattern import Pattern # c1 = Crease((95, 20),(5, 65)) # c2 = Crease((5, 45),(95, 80)) # c3 = Crease((45, 5),(45, 95)) # creases = (c1, c2, c3) # x = Pattern("anarchy", (100, 100), creases) # g_list = Gcode("anarchy", x).to_string_list() # for c in g_list: # print(c) pl = PatternLoader("images/") p = pl.loadPattern("frog.png") #p.save_to_text("patterndb/", "frog") g = Gcode("frog", p).to_string_list() # for c in g: # print(c) # print(sum((1,2)))
def setUp(self): self.a = Gcode()
for fname, color, angle in zip(fnames, colors, angles): mesh = trimesh.load_mesh(path + fname) meshes.append(mesh) section = mesh.section(plane_origin=[0, 0, 0.01], plane_normal=[0, 0, 1]) loops = section.discrete for loop in loops: outline = Outline() outline._name = fname outline.addCoordLoop(loop * 1000) # 1000 to convert from meters to mm outline = outline.translate(-50, -12) secAngs.append(SecAng(Section(outline), angle)) plt.plot(loop[:, 0] - 0.050, loop[:, 1] - 0.012, color) params.outline = [tuple(secAngs)] gCode = Gcode(params) plt.show() def run(): startTime = time.time() print('\nGenerating code, please wait...') fig = fg.Figura(params, gCode) with open(path + params.outputFileName, 'w') as f: for string in fig.masterGcode_gen(): f.write(string) endTime = time.time() print('\nCode generated.')
from deck import Deck from gcode import Gcode deck = Deck("./deck.yaml") gcode = Gcode(deck)
382 159 755 6 381 758 491 491 395 583 491 491 395 583 603 379 435 624 491 491 435 624 752 755 491 491 625 435 491 491 752 755 491 491 758 381 491 269 603 379 491 269 755 6 603 379 625 435 603 379 755 6 603 379 758 381 ''' pl = PatternLoader("../images/") p = pl.loadPattern("frog.png") textLoader = Pattern(None, None, None) cranep = textLoader.load_from_string("cranep", x) g = Gcode("cranep", cranep).to_string_list() for c in g: print(c)