@@ -96,6 +96,8 @@ def __init__(self):
9696 """ [dict|list(dict)=[]] Diff resources, usually one for the PCB and another for the schematic """
9797 self .ibom = ''
9898 """ Name of the iBoM output. Use `None` to skip """
99+ self .bom = ''
100+ """ Name of the BoM output to use as embedded HTML. Use `None` to skip """
99101 self .assembly_models = KiCad_SiteAssembly
100102 """ [dict|list(dict)=[]] 3D assembly models """
101103 self .force_copy = False
@@ -142,6 +144,12 @@ def _get_targets(self, out_dir, only_index=False):
142144 if out_name :
143145 file , subdir = self .solve_download (KiCad_SiteDownload (output = out_name ), kind = 'iBoM' , dry_run = True )
144146 self .add_target_name (file , subdir )
147+ # BoM
148+ if self .bom != 'None' :
149+ out_name = self .get_bom ()
150+ if out_name :
151+ file , subdir = self .solve_download (KiCad_SiteDownload (output = out_name ), kind = 'BoM' , dry_run = True )
152+ self .add_target_name (file , subdir )
145153 # Assembly models
146154 if self .assembly_models :
147155 for o in self .assembly_models :
@@ -164,6 +172,14 @@ def get_ibom(self, fail=False):
164172 return out .name if out else None
165173 return self .ibom
166174
175+ def get_bom (self , fail = False ):
176+ if not self .bom :
177+ out = next (filter (lambda x : x .type == 'bom' and x .options ._format == 'html' , RegOutput .get_outputs ()), None )
178+ if not out :
179+ raise KiPlotConfigurationError ("No BoM output specified and I can't find it, use `None`" )
180+ return out .name if out else None
181+ return self .bom
182+
167183 def get_dependencies (self ):
168184 # PCB & Schematic
169185 deps = {GS .pcb_file }
@@ -183,6 +199,11 @@ def get_dependencies(self):
183199 out_name = self .get_ibom ()
184200 if out_name :
185201 deps .add (out_name )
202+ # BoM
203+ if self .bom != 'None' :
204+ out_name = self .get_bom ()
205+ if out_name :
206+ deps .add (out_name )
186207 # Assembly models
187208 deps .update ([o .output for o in self .assembly_models ])
188209 return sorted (deps )
@@ -342,6 +363,13 @@ def run(self, dir_name):
342363 self .copy (file , subdir )
343364 cfg += f' ibom: "{ os .path .join (subdir , os .path .basename (file ))} "\n '
344365
366+ # BoM
367+ if self .bom != 'None' :
368+ out_name = self .get_bom (fail = True )
369+ file , subdir = self .solve_download (KiCad_SiteDownload (output = out_name ), kind = 'BoM' )
370+ self .copy (file , subdir )
371+ cfg += f' bom: "{ os .path .join (subdir , os .path .basename (file ))} "\n '
372+
345373 # Assembly models
346374 cfg += ' assemblyDir: "."\n '
347375 if self .assembly_models :
0 commit comments