def test_PolyShaperOranje(self): #pylint: disable=invalid-name """ Tests definition for the Oranje """ machine = machine_factory("PolyShaperOranje") self.assertEqual(machine.name(), "PolyShaper Oranje") self.assertEqual(machine.working_area_width(), 500) self.assertEqual(machine.working_area_height(), 500)
def test_PolyShaperAzulPlus(self): #pylint: disable=invalid-name """ Tests definition for the P1000plus """ machine = machine_factory("PolyShaperAzul+") self.assertEqual(machine.name(), "PolyShaper Azul+") self.assertEqual(machine.working_area_width(), 1200) self.assertEqual(machine.working_area_height(), 600)
def test_P400(self): #pylint: disable=invalid-name """ Tests definition for the P400 """ machine = machine_factory("P400") self.assertEqual(machine.name(), "P400") self.assertEqual(machine.working_area_width(), 400) self.assertEqual(machine.working_area_height(), 400)
def test_return_None_for_invalid_names(self): #pylint: disable=invalid-name """ Tests that the factory returns None for invalid names """ self.assertIsNone(machine_factory("bla bla bla"))
def effect(self): """ Main function """ # First of all generating the machine instance and checking piece dimensions fit machine = machine_factory(self.options.machine_type) if machine: valid_dimensions = machine.piece_dimensions_allowed( self.options.dim_x, self.options.dim_y) if not valid_dimensions: raise InvalidWorkpieceDimensions(machine.working_area_width(), machine.working_area_height()) # A function to convert to millimiters to_mm = lambda value: self.uutounit(value, 'mm') # A function to convert to user units. This must be used to write units in the svg to_uu = lambda value: self.unittouu(str(value) + "mm") # Draw the working area working_area_generator = WorkingAreaGenerator(to_uu, WORKING_AREA_ID) working_area_generator.set_size(self.options.dim_x, self.options.dim_y) working_area_generator.upsert(self.document.getroot()) if not self.options.ids: # print info and exit inkex.debug( _(("No path was seletect, only the working area was generated. Now draw a " "path inside the working area and select it to generate the g-code" ))) else: # Extracting paths in machine coordinates paths_extractor = PathsExtractor( self.selected.values(), to_mm, WORKING_AREA_ID, FlattenBezier(self.options.flatness), self.options.auto_close_path) paths_extractor.extract() # The border to use. This is None if no border is requested. If border is present, also # draws it border = None if self.options.square: border = Border(paths_extractor.paths(), self.options.margin) painter = BorderPainter(border) painter.paint(working_area_generator) # Joining paths. This will also check that all paths are closed paths_joiner = PathsJoiner(paths_extractor.paths(), CLOSE_DISTANCE) paths_joiner.unite() # Generate tool positions tool_path_generator = CuttingToolPathsGenerator( paths_joiner.union_path(), CLOSE_DISTANCE, border) tool_path_generator.generate() # The object drawing the tool path painter = ToolPathPainter(tool_path_generator.path()) # Draw tool path on original svg if requested if self.options.draw_toolpath: painter.paint(working_area_generator.get_element(), working_area_generator.get_factor(), "255,0,0") # Generating g-code gcode_generator = CuttingGCodeGenerator(tool_path_generator.path(), self.options.speed) gcode_generator.generate() # Computing information about path generic_filename = base_filename(self.options.shapename, self.gcode_file_path) info = PathInfo(tool_path_generator.path(), self.options, generic_filename) # Writing gcode to file write_file( os.path.join(self.gcode_file_path, info.gcode_filename()), lambda f: f.write(gcode_generator.gcode())) # Writing svg to file doc = generate_path_svg(painter) write_file(os.path.join(self.gcode_file_path, info.svg_filename()), lambda f: doc.write(f)) # Writing metainfo to file write_file( os.path.join(self.gcode_file_path, info.metainfo_filename()), lambda f: f.write(json.dumps(info.metainfo(), indent=2))) message = (_("The generate g-code has been saved to ") + info.gcode_filename() + _(". Estimated working time: ") + str(info.working_time_min()) + _(" minutes")) if not info.is_path_inside_workpiece(): message += _( ". WARNING: some points are outside the workpiece") inkex.debug(message)