MCPcopy
hub / github.com/scottbez1/splitflap / _render_component

Method _render_component

3d/scripts/projection_renderer.py:62–98  ·  view source on GitHub ↗
(self, i, panel_horizontal, panel_vertical)

Source from the content-addressed store, hash-verified

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'

Callers 1

render_svgsMethod · 0.95

Calls 7

_get_component_fileMethod · 0.95
_get_variablesMethod · 0.95
apply_laser_cut_styleMethod · 0.95
SvgProcessorClass · 0.90
appendMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected