Internal BoM: two other options for the sorting criteria.
This commit is contained in:
parent
644f6d1fda
commit
ed4ff70033
|
|
@ -61,6 +61,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- Added global options to define the PCB details (`pcb_material`,
|
||||
`solder_mask_color`, `silk_screen_color` and `pcb_finish`)
|
||||
- Report generation (for design house) (#93)
|
||||
- Internal BoM: two other options for the sorting criteria.
|
||||
|
||||
### Changed
|
||||
- Internal BoM: now components with different Tolerance, Voltage, Current
|
||||
|
|
|
|||
|
|
@ -359,7 +359,7 @@ class ComponentGroup(object):
|
|||
return row
|
||||
|
||||
|
||||
def get_value_sort(comp):
|
||||
def get_value_sort(comp, fallback_ref=False):
|
||||
""" Try to better sort R, L and C components """
|
||||
res = comp.value_sort
|
||||
if res:
|
||||
|
|
@ -371,6 +371,8 @@ def get_value_sort(comp):
|
|||
# milli Ohms
|
||||
value = "{0:15d}".format(int(value * 1000 * mult + 0.1))
|
||||
return value
|
||||
if fallback_ref:
|
||||
return comp.ref_prefix + "{0:15d}".format(_suffix_to_num(comp.ref_suffix))
|
||||
return comp.value
|
||||
|
||||
|
||||
|
|
@ -457,8 +459,16 @@ def group_components(cfg, components):
|
|||
if cfg.normalize_values:
|
||||
g.fields[ColumnList.COL_VALUE_L] = normalize_value(g.components[0], decimal_point)
|
||||
# Sort the groups
|
||||
# First priority is the Type of component (e.g. R?, U?, L?)
|
||||
groups = sorted(groups, key=lambda g: [g.components[0].ref_prefix, get_value_sort(g.components[0])])
|
||||
if cfg.sort_style == 'type_value':
|
||||
# First priority is the Type of component (e.g. R?, U?, L?)
|
||||
# Second is the value
|
||||
groups = sorted(groups, key=lambda g: [g.components[0].ref_prefix, get_value_sort(g.components[0])])
|
||||
elif cfg.sort_style == 'type_value_ref':
|
||||
# First priority is the Type of component (e.g. R?, U?, L?)
|
||||
# Second is the value, but if we don't have a value we use the reference
|
||||
groups = sorted(groups, key=lambda g: [g.components[0].ref_prefix, get_value_sort(g.components[0], True)])
|
||||
else: # ref
|
||||
groups = sorted(groups, key=lambda g: [g.components[0].ref_prefix, _suffix_to_num(g.components[0].ref_suffix)])
|
||||
# Enumerate the groups and compute stats
|
||||
n_total = n_total_smd = n_total_tht = 0
|
||||
n_fitted = n_fitted_smd = n_fitted_tht = 0
|
||||
|
|
|
|||
|
|
@ -386,6 +386,8 @@ class BoMOptions(BaseOptions):
|
|||
""" Show the stats about how many of the components are SMD/THT. You must provide the PCB """
|
||||
self.units = 'millimeters'
|
||||
""" [millimeters,inches] Units used for the positions ('Footprint X' and 'Footprint Y' columns) """
|
||||
self.sort_style = 'type_value'
|
||||
""" [type_value,type_value_ref,ref] Sorting criteria """
|
||||
self._format_example = 'CSV'
|
||||
super().__init__()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue