Fixed assembly counts in json nexted BOM.

Fixed assembly counts in build instructions.
This commit is contained in:
Chris Palmer 2019-06-17 19:34:46 +01:00
parent ad8d7ae311
commit 8d49f2b564
2 changed files with 6 additions and 4 deletions

View File

@ -54,11 +54,11 @@ class BOM:
self.routed = {}
self.assemblies = {}
def data(self, main):
def data(self, main, count = 1):
return {
"name" : self.name,
"count" : self.count,
"assemblies" : [main.assemblies[ass].data(main) for ass in self.assemblies],
"count" : count,
"assemblies" : [main.assemblies[ass].data(main, self.assemblies[ass].count) for ass in self.assemblies],
"vitamins" : self.vitamins,
"printed" : self.printed,
"routed" : self.routed

View File

@ -35,6 +35,7 @@ import blurb
import bom
import shutil
from colorama import Fore
import copy
def is_assembly(s):
return s[-9:] == '_assembly' or s[-11:] == '_assemblies'
@ -42,6 +43,7 @@ def is_assembly(s):
def add_assembly(flat_bom, bom, bounds_map):
for b in flat_bom:
if b["name"] == bom["name"]:
b["count"] += bom["count"]
return b
big = False
for ass in bom["assemblies"]:
@ -58,7 +60,7 @@ def add_assembly(flat_bom, bom, bounds_map):
break
bom["big"] = big or bom["routed"]
flat_bom.append(bom)
flat_bom.append(copy.deepcopy(bom))
return bom
def bom_to_assemblies(bom_dir, bounds_map):