[iBoM][Added] `forced_name` to control the displayed name
- To force the name displayed at the top left corner Closes #470
This commit is contained in:
parent
f9e774a1f5
commit
68e0ccc9b8
|
|
@ -6,8 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
|
||||
## [1.6.4] - UNRELEASED
|
||||
### Added
|
||||
- iBoM:
|
||||
- `forced_name` option to force the name displayed at the top left corner
|
||||
(#470)
|
||||
|
||||
### Fixed
|
||||
- Rotated polygons and text used in the worksheet (#466)
|
||||
- BoM:
|
||||
- Problems when trying to aggregate the datasheet field (#472)
|
||||
|
||||
|
||||
## [1.6.3] - 2023-06-26
|
||||
### Added
|
||||
|
|
|
|||
|
|
@ -2805,6 +2805,8 @@ Notes:
|
|||
IBoM option, avoid using in conjunction with KiBot variants/filters.
|
||||
- `extra_data_file`: [string=''] Path to netlist or xml file. You can use '%F.xml' to avoid specifying the project name.
|
||||
Leave it blank for most uses, data will be extracted from the PCB.
|
||||
- `forced_name`: [string=''] Name to be used for the PCB/project (no file extension).
|
||||
This will affect the name iBoM displays in the generated HTML.
|
||||
- `group_fields`: [string=''] Comma separated list of fields that components will be grouped by.
|
||||
Value and Footprint are used when nothing is specified.
|
||||
- `hide_excluded`: [boolean=false] Hide components in the Fab layer that are marked as excluded by a variant.
|
||||
|
|
|
|||
|
|
@ -1235,6 +1235,9 @@ outputs:
|
|||
# [string=''] Comma separated list of extra fields to pull from netlist or xml file.
|
||||
# Using 'X,Y' is a shortcut for `show_fields` and `group_fields` with values 'Value,Footprint,X,Y'
|
||||
extra_fields: ''
|
||||
# [string=''] Name to be used for the PCB/project (no file extension).
|
||||
# This will affect the name iBoM displays in the generated HTML
|
||||
forced_name: ''
|
||||
# [string=''] Comma separated list of fields that components will be grouped by.
|
||||
# Value and Footprint are used when nothing is specified
|
||||
group_fields: ''
|
||||
|
|
|
|||
|
|
@ -885,12 +885,13 @@ class VariantOptions(BaseOptions):
|
|||
return fname
|
||||
|
||||
@staticmethod
|
||||
def save_tmp_dir_board(id, force_dir=None):
|
||||
def save_tmp_dir_board(id, force_dir=None, forced_name=None):
|
||||
""" Save the PCB to a temporal dir.
|
||||
Disadvantage: all relative paths inside the file becomes useless
|
||||
Aadvantage: the name of the file remains the same """
|
||||
pcb_dir = mkdtemp(prefix='tmp-kibot-'+id+'-') if force_dir is None else force_dir
|
||||
fname = os.path.join(pcb_dir, GS.pcb_basename+'.kicad_pcb')
|
||||
basename = forced_name if forced_name else GS.pcb_basename
|
||||
fname = os.path.join(pcb_dir, basename+'.kicad_pcb')
|
||||
logger.debug('Storing modified PCB to `{}`'.format(fname))
|
||||
GS.board.Save(fname)
|
||||
pro_name = GS.copy_project(fname)
|
||||
|
|
|
|||
|
|
@ -120,6 +120,9 @@ class IBoMOptions(VariantOptions):
|
|||
self.hide_excluded = False
|
||||
""" Hide components in the Fab layer that are marked as excluded by a variant.
|
||||
Affected by global options """
|
||||
self.forced_name = ''
|
||||
""" Name to be used for the PCB/project (no file extension).
|
||||
This will affect the name iBoM displays in the generated HTML """
|
||||
super().__init__()
|
||||
self.add_to_doc('variant', WARNING_MIX)
|
||||
self.add_to_doc('dnf_filter', WARNING_MIX)
|
||||
|
|
@ -177,15 +180,17 @@ class IBoMOptions(VariantOptions):
|
|||
pcb_name = GS.pcb_file
|
||||
if self.will_filter_pcb_components():
|
||||
# Write a custom netlist to a temporal dir
|
||||
prj_name = os.path.basename(self.expand_filename('', self.forced_name, 'ibom', '')) if self.forced_name \
|
||||
else GS.pcb_basename
|
||||
net_dir = mkdtemp(prefix='tmp-kibot-ibom-')
|
||||
netlist = os.path.join(net_dir, GS.pcb_basename+'.xml')
|
||||
netlist = os.path.join(net_dir, prj_name+'.xml')
|
||||
self.extra_data_file = netlist
|
||||
logger.debug('Creating variant netlist `{}`'.format(netlist))
|
||||
with open(netlist, 'wb') as f:
|
||||
GS.sch.save_netlist(f, self._comps)
|
||||
# Write a board with the filtered values applied
|
||||
self.filter_pcb_components()
|
||||
pcb_name, _ = self.save_tmp_dir_board('ibom', force_dir=net_dir)
|
||||
pcb_name, _ = self.save_tmp_dir_board('ibom', force_dir=net_dir, forced_name=prj_name)
|
||||
self.unfilter_pcb_components()
|
||||
else:
|
||||
# Check if the user wants extra_fields but there is no data about them (#68)
|
||||
|
|
@ -208,7 +213,7 @@ class IBoMOptions(VariantOptions):
|
|||
self.blacklist += to_remove
|
||||
# Convert attributes into options
|
||||
for k, v in self.get_attrs_gen():
|
||||
if not v or k in ['output', 'variant', 'dnf_filter', 'pre_transform', 'hide_excluded']:
|
||||
if not v or k in ['output', 'variant', 'dnf_filter', 'pre_transform', 'hide_excluded', 'forced_name']:
|
||||
continue
|
||||
if k == 'offset_back_rotation' and version < (2, 5, 0, 2):
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ outputs:
|
|||
dir: BoM
|
||||
options:
|
||||
variant: t1_v1
|
||||
forced_name: '%f, %V'
|
||||
|
||||
- name: 'bom_internal_v2'
|
||||
comment: "Bill of Materials in CSV format for variant t1_v2"
|
||||
|
|
|
|||
Loading…
Reference in New Issue