diff --git a/kiplot/bom/bom.py b/kiplot/bom/bom.py index 54a8f897..33d3f16c 100644 --- a/kiplot/bom/bom.py +++ b/kiplot/bom/bom.py @@ -4,7 +4,6 @@ This code is adapted from https://github.com/SchrodingersGat/KiBoM by Oliver Hen Here is all the logic to convert a list of components into the rows and columns used to create the BoM. """ -# TODO Sheetpath from .units import compare_values, comp_match from .bom_writer import write_bom from .columnlist import ColumnList @@ -237,10 +236,8 @@ class ComponentGroup(object): def update_fields(self, usealt=False): for c in self.components: - for f in c.get_field_names(): - # TODO optimize the list is simple and positions fixed - # Value and datasheet aren't special - self.update_field(f, c.get_field_value(f)) + for f, v in c.get_user_fields(): + self.update_field(f, v) # Update 'global' fields if usealt: self.fields[ColumnList.COL_REFERENCE_L] = self.get_alt_refs() diff --git a/kiplot/kicad/v5_sch.py b/kiplot/kicad/v5_sch.py index 6940cc52..360ec0d4 100644 --- a/kiplot/kicad/v5_sch.py +++ b/kiplot/kicad/v5_sch.py @@ -583,6 +583,12 @@ class SchematicComponent(object): def get_field_names(self): return [f.name for f in self.fields] + def get_user_fields(self): + """ Returns a list of tuples with the user defined fields (name, value) """ + if len(self.fields) < 4: + return [] + return [(f.name, f.value) for f in self.fields[4:]] + def add_field(self, field): self.fields.append(field) self.dfields[field.name.lower()] = field