(self, i, panel_horizontal, panel_vertical)
| 60 | return os.path.join(self.output_folder, 'component_%05d.svg' % i) |
| 61 | |
| 62 | def _render_component(self, i, panel_horizontal, panel_vertical): |
| 63 | output_file = self._get_component_file(i) |
| 64 | style_options = ['cut'] |
| 65 | if self.etch_enabled: |
| 66 | style_options.append('etch') |
| 67 | for style in (style_options): |
| 68 | logging.debug('Rendering component %d, %s', i, style) |
| 69 | try: |
| 70 | _ = openscad.run( |
| 71 | self.input_file, |
| 72 | output_file, |
| 73 | variables=self._get_variables({ |
| 74 | 'render_3d': False, |
| 75 | 'render_index': i, |
| 76 | 'render_etch': style == 'etch', |
| 77 | 'panel_horizontal': panel_horizontal, |
| 78 | 'panel_vertical': panel_vertical, |
| 79 | }), |
| 80 | capture_output=True, |
| 81 | ) |
| 82 | except openscad.OpenSCADException as e: |
| 83 | if b'Current top level object is not a 2D object.' in e.stderr: |
| 84 | # This is expected if we try rendering an etch layer as a |
| 85 | # cut, since there will be nothing to export |
| 86 | continue |
| 87 | else: |
| 88 | raise |
| 89 | |
| 90 | processor = SvgProcessor(output_file) |
| 91 | if style == 'cut': |
| 92 | processor.apply_laser_cut_style() |
| 93 | elif style == 'etch': |
| 94 | processor.apply_laser_etch_style() |
| 95 | return processor |
| 96 | |
| 97 | logging.debug('Component %d has no geometry', i) |
| 98 | return None |
| 99 | |
| 100 | def render_svgs(self, panelize_quantity): |
| 101 | assert panelize_quantity == 1 or panelize_quantity % 2 == 0, 'Panelize quantity must be 1 or an even number' |
no test coverage detected