diff --git a/README.md b/README.md index 2440e475..6a4e19fc 100644 --- a/README.md +++ b/README.md @@ -2890,7 +2890,7 @@ Notes: Note that the YAML section of the file will be skipped, all the needed information comes from this output and the `renderer` output. - **`renderer`**: [string=''] Name of the output used to render the PCB steps. - Currently this must be a `pcbdraw` output. + Currently this must be a `pcbdraw` or `render_3d` output. - `dnf_filter`: [string|list(string)='_none'] Name of the filter to mark components as not fitted. A short-cut to use for simple cases where a variant is an overkill. - `imgname`: [string='img/populating_%d.%x'] Pattern used for the image names. The `%d` is replaced by the image number. diff --git a/docs/samples/generic_plot.kibot.yaml b/docs/samples/generic_plot.kibot.yaml index 7c88018f..1d31f17f 100644 --- a/docs/samples/generic_plot.kibot.yaml +++ b/docs/samples/generic_plot.kibot.yaml @@ -1663,7 +1663,7 @@ outputs: # A short-cut to use for simple cases where a variant is an overkill pre_transform: '_none' # [string=''] Name of the output used to render the PCB steps. - # Currently this must be a `pcbdraw` output + # Currently this must be a `pcbdraw` or `render_3d` output renderer: '' # [string] The name of the handlebars template used for the HTML output. # The extension must be `.handlebars`, it will be added when missing. diff --git a/kibot/out_populate.py b/kibot/out_populate.py index 5bc9ad32..84ea7bb4 100644 --- a/kibot/out_populate.py +++ b/kibot/out_populate.py @@ -43,7 +43,7 @@ class PopulateOptions(VariantOptions): with document: self.renderer = '' """ *Name of the output used to render the PCB steps. - Currently this must be a `pcbdraw` output """ + Currently this must be a `pcbdraw` or `render_3d` output """ self.template = 'simple' """ [string] The name of the handlebars template used for the HTML output. The extension must be `.handlebars`, it will be added when missing. @@ -88,17 +88,21 @@ class PopulateOptions(VariantOptions): format(side, components, active_components, name)) # Configure it according to our needs options._filters_to_expand = False - options.bottom = side.startswith("back") options.show_components = [c for c in components if c] if not options.show_components: - options.show_components = None + options.show_components = None if self._renderer_is_pcbdraw else [] else: - options.show_components = options.solve_filters(options.show_components) - options.add_to_variant = False - options.highlight = options.solve_filters([c for c in active_components if c]) + options.show_components = options.solve_kf_filters(options.show_components) + options.highlight = options.solve_kf_filters([c for c in active_components if c]) options.output = name self._renderer.dir = self._parent.dir self._renderer._done = False + if self._renderer_is_pcbdraw: + options.add_to_variant = False + options.bottom = side.startswith("back") + else: # render_3D + options.view = 'Z' if side.startswith("back") else 'z' + options._show_all_components = False run_output(self._renderer) return options.expand_filename_both(name, is_sch=False) @@ -106,25 +110,33 @@ class PopulateOptions(VariantOptions): """ Save the current renderer settings """ options = self._renderer.options self.old_filters_to_expand = options._filters_to_expand - self.old_bottom = options.bottom self.old_show_components = options.show_components - self.old_add_to_variant = options.add_to_variant self.old_highlight = options.highlight self.old_output = options.output self.old_dir = self._renderer.dir self.old_done = self._renderer._done + if self._renderer_is_pcbdraw: + self.old_bottom = options.bottom + self.old_add_to_variant = options.add_to_variant + else: # render_3D + self.old_view = options.view + self.old_show_all_components = options._show_all_components def restore_options(self): """ Restore the renderer settings """ options = self._renderer.options options._filters_to_expand = self.old_filters_to_expand - options.bottom = self.old_bottom options.show_components = self.old_show_components - options.add_to_variant = self.old_add_to_variant options.highlight = self.old_highlight options.output = self.old_output self._renderer.dir = self.old_dir self._renderer._done = self.old_done + if self._renderer_is_pcbdraw: + options.bottom = self.old_bottom + options.add_to_variant = self.old_add_to_variant + else: # render_3D + options.view = self.old_view + options._show_all_components = self.old_show_all_components def generate_images(self, dir_name, content): # Memorize the current options @@ -157,7 +169,10 @@ class PopulateOptions(VariantOptions): if out is None: raise KiPlotConfigurationError('Unknown output `{}` selected in {}'.format(self.renderer, self._parent)) config_output(out) + if out.type not in ['pcbdraw', 'render_3d']: + raise KiPlotConfigurationError('The `renderer` must be `pcbdraw` or `render_3d` type, not {}'.format(out.type)) self._renderer = out + self._renderer_is_pcbdraw = out.type == 'pcbdraw' # Load the input content try: _, content = load_content(self.input) diff --git a/tests/yaml_samples/populate_with_filter.kibot.yaml b/tests/yaml_samples/populate_with_filter.kibot.yaml index 656e9674..78857be7 100644 --- a/tests/yaml_samples/populate_with_filter.kibot.yaml +++ b/tests/yaml_samples/populate_with_filter.kibot.yaml @@ -45,10 +45,28 @@ outputs: options: format: png + - name: KiCad_3D + comment: "How to draw a step" + type: render_3d + run_by_default: false + options: + width: 1280 + height: 960 + orthographic: true + zoom: 4 + ray_tracing: true + # DAF1FF + background1: "#DAF1FF" + background2: "#DAF1FF" + # auto_crop: true + # auto_crop_color: "#00FF00" + # auto_crop_fuzz: 15 + + - name: Populate comment: "Populate example" type: populate dir: PopulateWithFilter options: - renderer: PcbDraw + renderer: KiCad_3D input: tests/data/with_filter_html.md