Skip to content

Commit

Permalink
[Blender Export][Added] option to avoid soldering heatsinks
Browse files Browse the repository at this point in the history
  • Loading branch information
set-soft committed Feb 14, 2025
1 parent 03c039b commit 506c869
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions docs/samples/generic_plot.kibot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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+
Expand Down
1 change: 1 addition & 0 deletions docs/source/Changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:`: <pair: output - pcb2blender_tools - options; solder_join_on_heatsink>` [:ref:`boolean <boolean>`] (default: ``true``) Solder the THT pads with heatsink fabrication attribute.
- ``stackup_create`` :index:`: <pair: output - pcb2blender_tools - options; stackup_create>` [:ref:`boolean <boolean>`] (default: ``false``) Create a file containing the board stackup.
- ``stackup_dir`` :index:`: <pair: output - pcb2blender_tools - options; stackup_dir>` [:ref:`string <string>`] (default: ``'.'``) Directory for the stackup file. Use 'layers' for 2.7+.
- ``stackup_file`` :index:`: <pair: output - pcb2blender_tools - options; stackup_file>` [:ref:`string <string>`] (default: ``'board.yaml'``) Name for the stackup file. Use 'stackup' for 2.7+.
Expand Down
1 change: 1 addition & 0 deletions docs/source/configuration/outputs/PCB3DExportOptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:`: <pair: output - blender_export - options - pcb3d; solder_join_on_heatsink>` [:ref:`boolean <boolean>`] (default: ``true``) Solder the THT pads with heatsink fabrication attribute.
- ``solder_paste_for_populated`` :index:`: <pair: output - blender_export - options - pcb3d; solder_paste_for_populated>` [:ref:`boolean <boolean>`] (default: ``true``) Add solder paste only for the populated components.
Populated components are the ones listed in `show_components`.
- ``variant`` :index:`: <pair: output - blender_export - options - pcb3d; variant>` [:ref:`string <string>`] (default: ``''``) Board variant to apply.
Expand Down
7 changes: 5 additions & 2 deletions kibot/out_blender_export.py
Original file line number Diff line number Diff line change
@@ -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)
"""
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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',
Expand Down
24 changes: 19 additions & 5 deletions kibot/out_pcb2blender_tools.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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 """
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand Down
14 changes: 14 additions & 0 deletions tests/GUI/outputs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,13 @@
"DataTypeBoolean"
],
null
],
[
"solder_join_on_heatsink",
[
"DataTypeBoolean"
],
null
]
]
],
Expand Down Expand Up @@ -8502,6 +8509,13 @@
],
null
],
[
"solder_join_on_heatsink",
[
"DataTypeBoolean"
],
null
],
[
"variant",
[
Expand Down
24 changes: 12 additions & 12 deletions tests/GUI/stats
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -140,7 +140,7 @@ Outputs sorted by depth:
--------------------------------------------------------------------------------
14 different data types
- String: 870
- Boolean: 500
- Boolean: 502
- Number: 282
- ListStringSingular: 267
- Choice: 101
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -615,7 +615,7 @@ Totals sorted by depth:
--------------------------------------------------------------------------------
14 different data types
- String: 1023
- Boolean: 600
- Boolean: 602
- Number: 332
- ListStringSingular: 296
- Choice: 133
Expand All @@ -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
Expand Down

0 comments on commit 506c869

Please sign in to comment.