def get_gcode_scaffold(self, extruders, extruder_temperature, platform_temperature, material_name): tool_0 = '0' in extruders tool_1 = '1' in extruders gcode_assembler = makerbot_driver.GcodeAssembler( self._s3g_profile, self._s3g_profile.path) tuple_ = gcode_assembler.assemble_recipe(tool_0=tool_0, tool_1=tool_1, material=material_name) start_template, end_template, variables = tuple_ variables['TOOL_0_TEMP'] = extruder_temperature variables['TOOL_1_TEMP'] = extruder_temperature variables['PLATFORM_TEMP'] = platform_temperature start_position = self._s3g_profile.values['print_start_sequence'][ 'start_position'] variables['START_X'] = start_position['start_x'] variables['START_Y'] = start_position['start_y'] variables['START_Z'] = start_position['start_z'] gcode_scaffold = conveyor.machine.GcodeScaffold() gcode_scaffold.start = gcode_assembler.assemble_start_sequence( start_template) gcode_scaffold.end = gcode_assembler.assemble_end_sequence( end_template) gcode_scaffold.variables = variables return gcode_scaffold
def get_start_end_variables(profile, slicer_settings, material, dualstrusion): """ This function is static so it can be invoked be the verify gcode task. @returns tuple of (start gcode block, end gcode block, variables) """ tool_0, tool_1 = False, False if None is material: material = 'PLA' if dualstrusion: tool_0 = True tool_1 = True else: extruders = [e.strip() for e in slicer_settings.extruder.split(',')] if '0' in extruders: tool_0 = True if '1' in extruders: tool_1 = True ga = makerbot_driver.GcodeAssembler(profile._s3g_profile, profile._s3g_profile.path) start_template, end_template, variables = ga.assemble_recipe( tool_0=tool_0, tool_1=tool_1, material=material) start_gcode = ga.assemble_start_sequence(start_template) end_gcode = ga.assemble_end_sequence(end_template) variables['TOOL_0_TEMP'] = slicer_settings.extruder_temperature variables['TOOL_1_TEMP'] = slicer_settings.extruder_temperature variables['PLATFORM_TEMP'] = slicer_settings.platform_temperature start_position = profile._s3g_profile.values['print_start_sequence']['start_position'] variables['START_X'] = start_position['start_x'] variables['START_Y'] = start_position['start_y'] variables['START_Z'] = start_position['start_z'] return start_gcode, end_gcode, variables
def create_parser(self): factory = makerbot_driver.MachineFactory() machine = factory.build_from_port(self.usb_info.get('COM')) assembler = makerbot_driver.GcodeAssembler(machine.profile) parser = machine.gcodeparser start, end, variables = assembler.assemble_recipe() parser.environment.update(variables) return parser
def _get_start_end_variables(self, profile, slicer_settings, material): if None is material: material = 'PLA' ga = makerbot_driver.GcodeAssembler(profile, profile.path) start_template, end_template, variables = ga.assemble_recipe( material=material) start_gcode = ga.assemble_start_sequence(start_template) end_gcode = ga.assemble_end_sequence(end_template) variables['TOOL_0_TEMP'] = slicer_settings.extruder_temperature variables['TOOL_1_TEMP'] = slicer_settings.extruder_temperature variables['PLATFORM_TEMP'] = slicer_settings.platform_temperature return start_gcode, end_gcode, variables
def execute_file(the_file, parser): ga = makerbot_driver.GcodeAssembler(parser.state.profile) start, end, variables = ga.assemble_recipe() start_gcode = ga.assemble_start_sequence(start) end_gcode = ga.assemble_end_sequence(end) parser.environment.update(variables) for line in start_gcode: parser.execute_line(line) with open(the_file) as f: for line in f: parser.execute_line(line) for line in end_gcode: parser.execute_line(line)
def execute_file(the_file, parser): ga = makerbot_driver.GcodeAssembler(parser.state.profile) if "Thing-O-Matic" in parser.state.profile.values['machinenames']: start, end, variables = ga.assemble_recipe( begin_print='tom_begin', homing='tom_homing', start_position='tom_start_position', end_start_sequence='tom_end_start_sequence', end_position='tom_end_position', end_print='tom_end', ) else: start, end, variables = ga.assemble_recipe() start_gcode = ga.assemble_start_sequence(start) end_gcode = ga.assemble_end_sequence(end) parser.environment.update(variables) for line in start_gcode: parser.execute_line(line) with open(the_file) as f: for line in f: parser.execute_line(line) for line in end_gcode: parser.execute_line(line)
s = makerbot_driver.s3g() condition = threading.Condition() s.writer = makerbot_driver.Writer.FileWriter(fh, condition) profile = makerbot_driver.Profile(options.machine) filename = os.path.basename(input_file) filename = os.path.splitext(filename)[0] parser = makerbot_driver.Gcode.GcodeParser() parser.state.values["build_name"] = filename parser.state.profile = profile parser.s3g = s ga = makerbot_driver.GcodeAssembler(profile) start, end, variables = ga.assemble_recipe() start_gcode = ga.assemble_start_sequence(start) end_gcode = ga.assemble_end_sequence(end) parser.environment.update(variables) try: if options.sequences: for line in start_gcode: parser.execute_line(line) except Exception, e: validGcode = False print(e) try: with open(input_file) as f:
action="store_false") (options, args) = parser.parse_args() if options.port == None: md = makerbot_driver.MachineDetector() md.scan(options.machine) port = md.get_first_machine() if port is None: print "Can't Find %s" % (options.machine) sys.exit() else: port = options.port factory = makerbot_driver.BotFactory() r, prof = factory.build_from_port(port) assembler = makerbot_driver.GcodeAssembler(prof) start, end, variables = assembler.assemble_recipe() start_gcode = assembler.assemble_start_sequence(start) end_gcode = assembler.assemble_end_sequence(end) filename = os.path.basename(options.filename) filename = os.path.splitext(filename)[0] parser = makerbot_driver.Gcode.GcodeParser() parser.environment.update(variables) #Truncate name due to length restriction parser.state.values["build_name"] = filename[:15] parser.state.profile = prof parser.s3g = r if options.sequences:
def setUp(self): self.profile = makerbot_driver.Profile('ReplicatorDual') self.ga = makerbot_driver.GcodeAssembler(self.profile) self.recipes = makerbot_driver.Profile('recipes')
action="store_false") (options, args) = parser.parse_args() if options.port is None: md = makerbot_driver.MachineDetector() md.scan(options.machine) port = md.get_first_machine() if port is None: print "Can't Find %s" % (options.machine) sys.exit() else: port = options.port factory = makerbot_driver.MachineFactory() obj = factory.build_from_port(port) assembler = makerbot_driver.GcodeAssembler(getattr(obj, 'profile')) start, end, variables = assembler.assemble_recipe() start_gcode = assembler.assemble_start_sequence(start) end_gcode = assembler.assemble_end_sequence(end) filename = os.path.basename(options.filename) filename = os.path.splitext(filename)[0] parser = getattr(obj, 'gcodeparser') parser.environment.update(variables) parser.state.values["build_name"] = filename[:15] if options.sequences: for line in start_gcode: parser.execute_line(line) with open(options.filename) as f:
dest="sequences", help="Flag to not use makerbot_driver's start/end sequences", default=True, action="store_false") parser.add_option("-m", "--machine_type", dest="machine", help="machine type", default="ReplicatorDual") (options, args) = parser.parse_args() parser = makerbot_driver.create_print_to_file_parser(options.output_file, 'TOMStepstruderSingle', legacy=True) assembler = makerbot_driver.GcodeAssembler(parser.state.profile) start, end, variables = assembler.assemble_recipe( material='ABS', begin_print='tom_begin', homing='tom_homing', start_position='tom_start_position', end_start_sequence='tom_end_start_sequence', end_position='tom_end_position', end_print='tom_end', ) start_gcode = assembler.assemble_start_sequence(start) end_gcode = assembler.assemble_end_sequence(end) filename = os.path.basename(options.input_file) filename = os.path.splitext(filename)[0]
def main(): parser = optparse.OptionParser() parser.add_option( "-f", "--filename", dest="filename", help="gcode file to print", default=False) parser.add_option( "-m", "--machine", dest="machine", help="machine type to scan for, example ReplicatorSingle", default="The Replicator 2") parser.add_option( "-p", "--port", dest="port", help="The port you want to connect to (OPTIONAL)", default=None) parser.add_option( "-s", "--sequences", dest="sequences", help="Flag to not use makerbot_driver's start/end sequences", default=False, action="store_true") (options, args) = parser.parse_args() if options.port is None: md = makerbot_driver.MachineDetector() md.scan(options.machine) port = md.get_first_machine() if port is None: print "Can't Find %s" % (options.machine) sys.exit() else: port = options.port factory = makerbot_driver.MachineFactory() obj = factory.build_from_port(port) assembler = makerbot_driver.GcodeAssembler(getattr(obj, 'profile')) start, end, variables = assembler.assemble_recipe() start_gcode = assembler.assemble_start_sequence(start) end_gcode = assembler.assemble_end_sequence(end) filename = os.path.basename(options.filename) filename = os.path.splitext(filename)[0] parser = getattr(obj, 'gcodeparser') parser.environment.update(variables) parser.state.values["build_name"] = filename[:15] log.info('Using %s on %s with %s', factory, port, variables) def exec_line(line): while True: try: parser.execute_line(line) break except makerbot_driver.BufferOverflowError: try: parser.s3g.writer._condition.wait(.2) except RuntimeError: time.sleep(.2) if options.sequences: for line in start_gcode: exec_line(line) with open(options.filename) as f: for line in f: exec_line(line) if options.sequences: for line in end_gcode: exec_line(line)