def _render_component(self, i): output_file = self._get_component_file(i) for style in ('cut', 'etch'): logging.debug('Rendering component %d, %s', i, style) try: stdout, stderr = openscad.run( self.input_file, output_file, variables = self._get_variables({ 'render_3d': False, 'render_index': i, 'render_etch': style == 'etch', }), capture_output=True, ) except openscad.OpenSCADException as e: if 'Current top level object is not a 2D object.' in e.stderr: # This is expected if we try rendering an etch layer as a # cut, since there will be nothing to export continue else: raise processor = SvgProcessor(output_file) processor.fix_dimens() if style == 'cut': processor.apply_laser_cut_style() elif style == 'etch': processor.apply_laser_etch_style() break else: raise ValueError("Invalid component!", i) return processor
def _render_component(self, i, panel_horizontal, panel_vertical): output_file = self._get_component_file(i) style_options = ['cut'] if self.etch_enabled: style_options.append('etch') for style in (style_options): logging.debug('Rendering component %d, %s', i, style) try: _ = openscad.run( self.input_file, output_file, variables=self._get_variables({ '_is_projection_rendering': True, 'render_3d': False, 'render_index': i, 'render_etch': style == 'etch', 'panel_horizontal': panel_horizontal, 'panel_vertical': panel_vertical, }), capture_output=True, ) except openscad.OpenSCADException as e: if b'Current top level object is not a 2D object.' in e.stderr: # This is expected if we try rendering an etch layer as a # cut, since there will be nothing to export continue else: raise processor = SvgProcessor(output_file) if style == 'cut': processor.apply_laser_cut_style() elif style == 'etch': processor.apply_laser_etch_style() return processor logging.debug('Component %d has no geometry', i) return None
def _render_component(self, i, panel_horizontal, panel_vertical): output_file = self._get_component_file(i) for style in ('cut', 'etch'): logging.debug('Rendering component %d, %s', i, style) try: _ = openscad.run( self.input_file, output_file, variables=self._get_variables({ 'render_3d': False, 'render_index': i, 'render_etch': style == 'etch', 'panel_horizontal': panel_horizontal, 'panel_vertical': panel_vertical, }), capture_output=True, ) except openscad.OpenSCADException as e: if 'Current top level object is not a 2D object.' in e.stderr: # This is expected if we try rendering an etch layer as a # cut, since there will be nothing to export continue else: raise processor = SvgProcessor(output_file) processor.fix_dimens() if style == 'cut': processor.apply_laser_cut_style() elif style == 'etch': processor.apply_laser_etch_style() break else: raise ValueError("Invalid component!", i) return processor