From 506c869407ee39d27a62a019619b440fde8ffce9 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Fri, 14 Feb 2025 13:32:26 -0300 Subject: [PATCH] [Blender Export][Added] option to avoid soldering heatsinks --- CHANGELOG.md | 1 + docs/samples/generic_plot.kibot.yaml | 4 ++++ docs/source/Changelog.rst | 1 + .../outputs/PCB2Blender_ToolsOptions.rst | 1 + .../outputs/PCB3DExportOptions.rst | 1 + kibot/out_blender_export.py | 7 ++++-- kibot/out_pcb2blender_tools.py | 24 +++++++++++++++---- tests/GUI/outputs | 14 +++++++++++ tests/GUI/stats | 24 +++++++++---------- 9 files changed, 58 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 20692a64b..79471991e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `work_layer`: to choose the temporal layer for internal operations (#713) - Workaround for people using backslashes (i.e. Windows+WSL) (#719) (#607) More general than in previous versions. +- Blender Export: option to avoid soldering heatsinks - Boardview: OBDATA support - BoM: - Field aliases ${QUANTITY} and ${ITEM_NUMBER} for compatibility with diff --git a/docs/samples/generic_plot.kibot.yaml b/docs/samples/generic_plot.kibot.yaml index 2c118876f..e297a515d 100644 --- a/docs/samples/generic_plot.kibot.yaml +++ b/docs/samples/generic_plot.kibot.yaml @@ -342,6 +342,8 @@ outputs: # Ranges like *R5-R10* are supported. # Unlike the `pcbdraw` output, the default is `all` show_components: 'all' + # [boolean=true] Solder the THT pads with heatsink fabrication attribute + solder_join_on_heatsink: true # [boolean=true] Add solder paste only for the populated components. # Populated components are the ones listed in `show_components` solder_paste_for_populated: true @@ -2871,6 +2873,8 @@ outputs: # [list(string)|string='all'] [none,all,*] List of components to include in the pads list, # can be also a string for `none` or `all`. Ranges like *R5-R10* are supported show_components: 'all' + # [boolean=true] Solder the THT pads with heatsink fabrication attribute + solder_join_on_heatsink: true # [boolean=false] Create a file containing the board stackup stackup_create: false # [string='.'] Directory for the stackup file. Use 'layers' for 2.7+ diff --git a/docs/source/Changelog.rst b/docs/source/Changelog.rst index 0e986faf6..006b12325 100644 --- a/docs/source/Changelog.rst +++ b/docs/source/Changelog.rst @@ -47,6 +47,7 @@ Added - Workaround for people using backslashes (i.e. Windows+WSL) (#719) (#607) More general than in previous versions. +- Blender Export: option to avoid soldering heatsinks - Boardview: OBDATA support - BoM: diff --git a/docs/source/configuration/outputs/PCB2Blender_ToolsOptions.rst b/docs/source/configuration/outputs/PCB2Blender_ToolsOptions.rst index 9ee3dda6b..3014c16ad 100644 --- a/docs/source/configuration/outputs/PCB2Blender_ToolsOptions.rst +++ b/docs/source/configuration/outputs/PCB2Blender_ToolsOptions.rst @@ -29,6 +29,7 @@ PCB2Blender_ToolsOptions parameters Can be used to fine-tune a variant for a particular output that needs extra filtering done before the variant. +- ``solder_join_on_heatsink`` :index:`: ` [:ref:`boolean `] (default: ``true``) Solder the THT pads with heatsink fabrication attribute. - ``stackup_create`` :index:`: ` [:ref:`boolean `] (default: ``false``) Create a file containing the board stackup. - ``stackup_dir`` :index:`: ` [:ref:`string `] (default: ``'.'``) Directory for the stackup file. Use 'layers' for 2.7+. - ``stackup_file`` :index:`: ` [:ref:`string `] (default: ``'board.yaml'``) Name for the stackup file. Use 'stackup' for 2.7+. diff --git a/docs/source/configuration/outputs/PCB3DExportOptions.rst b/docs/source/configuration/outputs/PCB3DExportOptions.rst index f94b68df7..3c89e57f9 100644 --- a/docs/source/configuration/outputs/PCB3DExportOptions.rst +++ b/docs/source/configuration/outputs/PCB3DExportOptions.rst @@ -41,6 +41,7 @@ PCB3DExportOptions parameters Can be used to fine-tune a variant for a particular output that needs extra filtering done before the variant. +- ``solder_join_on_heatsink`` :index:`: ` [:ref:`boolean `] (default: ``true``) Solder the THT pads with heatsink fabrication attribute. - ``solder_paste_for_populated`` :index:`: ` [:ref:`boolean `] (default: ``true``) Add solder paste only for the populated components. Populated components are the ones listed in `show_components`. - ``variant`` :index:`: ` [:ref:`string `] (default: ``''``) Board variant to apply. diff --git a/kibot/out_blender_export.py b/kibot/out_blender_export.py index 9509233fa..1aee1221d 100644 --- a/kibot/out_blender_export.py +++ b/kibot/out_blender_export.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2023-2024 Salvador E. Tropea -# Copyright (c) 2023-2024 Instituto Nacional de Tecnología Industrial +# Copyright (c) 2023-2025 Salvador E. Tropea +# Copyright (c) 2023-2025 Instituto Nacional de Tecnología Industrial # License: AGPL-3.0 # Project: KiBot (formerly KiPlot) """ @@ -279,6 +279,8 @@ def __init__(self): self.solder_paste_for_populated = True """ Add solder paste only for the populated components. Populated components are the ones listed in `show_components` """ + self.solder_join_on_heatsink = True + """ Solder the THT pads with heatsink fabrication attribute """ self._expand_id = 'blender_export' self._expand_ext = 'pcb3d' self._unknown_is_error = True @@ -467,6 +469,7 @@ def create_pads(self, dest_dir, outputs): options['stackup_file'] = 'stackup' options['stackup_dir'] = 'layers' options['stackup_format'] = 'BIN' + options['solder_join_on_heatsink'] = self.pcb3d.solder_join_on_heatsink tree = {'name': '_temporal_pcb3d_tools', 'type': 'pcb2blender_tools', 'comment': 'Internally created for the PCB3D', diff --git a/kibot/out_pcb2blender_tools.py b/kibot/out_pcb2blender_tools.py index f8ef6e7bd..2699e0684 100644 --- a/kibot/out_pcb2blender_tools.py +++ b/kibot/out_pcb2blender_tools.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2023 Salvador E. Tropea -# Copyright (c) 2023 Instituto Nacional de Tecnología Industrial -# License: GPL-3.0 +# Copyright (c) 2023-2025 Salvador E. Tropea +# Copyright (c) 2023-2025 Instituto Nacional de Tecnología Industrial +# License: AGPL-3.0 # Project: KiBot (formerly KiPlot) # Some code is adapted from: https://github.com/30350n/pcb2blender from dataclasses import dataclass, field @@ -11,8 +11,10 @@ import re import struct from typing import List -from pcbnew import B_Paste, F_Paste, PCB_TEXT_T, ToMM from .gs import GS +from pcbnew import B_Paste, F_Paste, PCB_TEXT_T, ToMM +if GS.ki6: + from pcbnew import PAD_PROP_HEATSINK from .misc import (MOD_THROUGH_HOLE, MOD_SMD, UI_VIRTUAL, W_UNKPCB3DTXT, W_NOPCB3DBR, W_NOPCB3DTL, W_BADPCB3DTXT, W_UNKPCB3DNAME, W_BADPCB3DSTK, MISSING_TOOL) from .optionable import Optionable @@ -23,6 +25,12 @@ logger = log.get_logger() +def is_heatsink_pad(pad): + if not GS.ki6: + return False + return pad.GetProperty() == PAD_PROP_HEATSINK + + @dataclass class StackedBoard: """ Name and position of a stacked board """ @@ -106,6 +114,8 @@ def __init__(self): self.show_components = Optionable """ *[list(string)|string='all'] [none,all,*] List of components to include in the pads list, can be also a string for `none` or `all`. Ranges like *R5-R10* are supported """ + self.solder_join_on_heatsink = True + """ Solder the THT pads with heatsink fabrication attribute """ super().__init__() self._expand_id = 'pcb2blender' self._expand_ext = 'pcb3d' @@ -158,6 +168,8 @@ def do_pads_info(self, dir_name): value = value.replace('/', '_') reference = footprint.GetReference() for j, pad in enumerate(footprint.Pads()): + if not self.solder_join_on_heatsink and is_heatsink_pad(pad): + continue name = os.path.join(dir_name, sanitized("{}_{}_{}_{}".format(value, reference, i, j))) is_flipped = pad.IsFlipped() has_paste = pad.IsOnLayer(B_Paste if is_flipped else F_Paste) @@ -341,7 +353,9 @@ def get_targets(self, out_dir): for i, footprint in enumerate(GS.get_modules()): value = footprint.GetValue() reference = footprint.GetReference() - for j in range(len(footprint.Pads())): + for j, pad in enumerate(footprint.Pads()): + if not self.solder_join_on_heatsink and is_heatsink_pad(pad): + continue files.append(os.path.join(dir_name, sanitized("{}_{}_{}_{}".format(value, reference, i, j)))) if self.stackup_create and (GS.global_pcb_finish or GS.stackup): files.append(os.path.join(out_dir, self.stackup_dir, self.stackup_file)) diff --git a/tests/GUI/outputs b/tests/GUI/outputs index 7506995ea..15026811f 100644 --- a/tests/GUI/outputs +++ b/tests/GUI/outputs @@ -202,6 +202,13 @@ "DataTypeBoolean" ], null + ], + [ + "solder_join_on_heatsink", + [ + "DataTypeBoolean" + ], + null ] ] ], @@ -8502,6 +8509,13 @@ ], null ], + [ + "solder_join_on_heatsink", + [ + "DataTypeBoolean" + ], + null + ], [ "variant", [ diff --git a/tests/GUI/stats b/tests/GUI/stats index 16d1bc444..2f506a3af 100644 --- a/tests/GUI/stats +++ b/tests/GUI/stats @@ -1,5 +1,5 @@ -49 outputs types with a total of 1999 different parameters -Single type parameters: 1817 (91 %) +49 outputs types with a total of 2001 different parameters +Single type parameters: 1819 (91 %) Multi type parameters: 182 (9 %) Average parameters: 41 Maximum number of parameters: 217 @@ -54,8 +54,8 @@ Outputs sorted by parameters: - stencil_for_jig: 28 - copy_files: 29 - position: 30 -- pcb2blender_tools: 31 - pdf_pcb_print: 31 +- pcb2blender_tools: 32 - report: 33 - svg_pcb_print: 33 - vrml: 33 @@ -73,7 +73,7 @@ Outputs sorted by parameters: - pcbdraw: 59 - pdf: 65 - render_3d: 67 -- blender_export: 76 +- blender_export: 77 - pcb_print: 116 - bom: 149 - panelize: 217 @@ -140,7 +140,7 @@ Outputs sorted by depth: -------------------------------------------------------------------------------- 14 different data types - String: 870 -- Boolean: 500 +- Boolean: 502 - Number: 282 - ListStringSingular: 267 - Choice: 101 @@ -156,7 +156,7 @@ Outputs sorted by depth: -------------------------------------------------------------------------------- Used as single data type: - String: 710 -- Boolean: 439 +- Boolean: 441 - ListStringSingular: 264 - Number: 188 - Choice: 98 @@ -395,8 +395,8 @@ Used as single data type: - Number,String: 15 ================================================================================ ================================================================================ -88 totals types with a total of 2374 different parameters -Single type parameters: 2168 (91 %) +88 totals types with a total of 2376 different parameters +Single type parameters: 2170 (91 %) Multi type parameters: 206 (9 %) Average parameters: 27 Maximum number of parameters: 217 @@ -489,8 +489,8 @@ Totals sorted by parameters: - stencil_for_jig: 28 - copy_files: 29 - position: 30 -- pcb2blender_tools: 31 - pdf_pcb_print: 31 +- pcb2blender_tools: 32 - report: 33 - svg_pcb_print: 33 - vrml: 33 @@ -509,7 +509,7 @@ Totals sorted by parameters: - pcbdraw: 59 - pdf: 65 - render_3d: 67 -- blender_export: 76 +- blender_export: 77 - pcb_print: 116 - bom: 149 - panelize: 217 @@ -615,7 +615,7 @@ Totals sorted by depth: -------------------------------------------------------------------------------- 14 different data types - String: 1023 -- Boolean: 600 +- Boolean: 602 - Number: 332 - ListStringSingular: 296 - Choice: 133 @@ -631,7 +631,7 @@ Totals sorted by depth: -------------------------------------------------------------------------------- Used as single data type: - String: 847 -- Boolean: 531 +- Boolean: 533 - ListStringSingular: 293 - Number: 223 - Choice: 130