Skip to content

Commit

Permalink
Merge pull request #28 from diegoherranz/variant
Browse files Browse the repository at this point in the history
Use "variant" instead of "revision"
  • Loading branch information
SchrodingersGat authored Jan 28, 2018
2 parents 75cb5a6 + 8c918a0 commit bf7d800
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
10 changes: 5 additions & 5 deletions KiBOM_CLI.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
- Components are automatically grouped into BoM rows (grouping is configurable)
- Component groups count number of components and list component designators
- Rows are automatically sorted by component reference(s)
- Supports board revisions
- Supports board variants
Extended options are available in the "bom.ini" config file in the PCB directory (this file is auto-generated with default options the first time the script is executed).
Expand Down Expand Up @@ -60,7 +60,7 @@ def isExtensionSupported(filename):
parser.add_argument("output", default="", help='BoM output file name.\nUse "%%O" when running from within KiCad to use the default output name (csv file).\nFor e.g. HTML output, use "%%O.html"')
parser.add_argument("-n", "--number", help="Number of boards to build (default = 1)", type=int, default=1)
parser.add_argument("-v", "--verbose", help="Enable verbose output", action='count')
parser.add_argument("-r", "--revision", help="Board variant, used to determine which components are output to the BoM", type=str, default=None)
parser.add_argument("-r", "--variant", help="Board variant, used to determine which components are output to the BoM", type=str, default=None)
parser.add_argument("--cfg", help="BoM config file (script will try to use 'bom.ini' if not specified here)")
parser.add_argument("-s","--separator",help="CSV Separator (default ',')",type=str, default=None)

Expand Down Expand Up @@ -99,9 +99,9 @@ def isExtensionSupported(filename):
pref.boards = args.number
pref.separatorCSV = args.separator

if args.revision is not None:
pref.pcbConfig = args.revision
print("PCB Revision:",args.revision)
if args.variant is not None:
pref.pcbConfig = args.variant
print("PCB variant:", args.variant)

#write preference file back out (first run will generate a file with default preferences)
if not have_cfile:
Expand Down
28 changes: 17 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ The *KiBOM_CLI* script can be run directly from KiCad or from the command line.
`python KiBOM_CLI.py -h`

~~~~
usage: KiBOM_CLI.py [-h] [-n NUMBER] [-v] [-r VARIANT] [--cfg CFG]
[-s SEPARATOR]
netlist output
KiBOM Bill of Materials generator script
positional arguments:
Expand All @@ -30,12 +34,14 @@ optional arguments:
-n NUMBER, --number NUMBER
Number of boards to build (default = 1)
-v, --verbose Enable verbose output
-r REVISION, --revision REVISION
-r VARIANT, --variant VARIANT
Board variant, used to determine which components are
output to the BoM
--cfg CFG BoM config file (script will try to use 'bom.ini' if
not specified here)
-s SEPARATOR, --separator SEPARATOR
CSV Separator (default ',')
~~~~

Expand All @@ -52,7 +58,7 @@ optional arguments:

**-v --verbose** Enable extra debugging information

**-r --revision** Specify the PCB *revision*. Support for arbitrary PCB configurations allows individual components to be marked as 'fitted' or 'not fitted' in a given configuration.
**-r --variant** Specify the PCB *variant*. Support for arbitrary PCB variants allows individual components to be marked as 'fitted' or 'not fitted' in a given variant.

**--cfg** If provided, this is the BOM config file that will be used. If not provided, options will be loaded from "bom.ini"

Expand Down Expand Up @@ -133,27 +139,27 @@ To specify a part as DNF (do not fit), the *fit_field* field can be set to one o

If the *Value* field for the component contains any of these values, the component will also not be included

**PCB Configurations**
**PCB Variants**

To generate a BoM with a custom *Configuration*, the --revision flag can be used at the command line to specify which revision/configuration is to be used.
To generate a BoM with a custom *Variant*, the --variant flag can be used at the command line to specify which variant is to be used.

If a revision is specified, the value of the *fit_field* field is used to determine if a component will be included in the BoM, as follows:
If a variant is specified, the value of the *fit_field* field is used to determine if a component will be included in the BoM, as follows:

* If the *fit_field* value is empty / blank then it will be loaded in ALL configuration.
* If the *fit_field* begins with a '-' character, if will be excluded from the matching configuration.
* If the *fit_field* begins with a '+' character, if will ONLY be included in the matching configuration.
* If the *fit_field* value is empty / blank then it will be loaded in ALL variants.
* If the *fit_field* begins with a '-' character, if will be excluded from the matching variant.
* If the *fit_field* begins with a '+' character, if will ONLY be included in the matching variant.

Multiple configurations can be addressed as the *fit_field* can contain multiple comma-separated values.
Multiple variants can be addressed as the *fit_field* can contain multiple comma-separated values.

e.g. if we have a PCB with three components that have the following values in the *fit_field* field:

* C1 -> "-production"
* C2 -> "+production"
* R1 -> ""

If the script is run with the flag *--revision production* then C2 and R1 will be loaded.
If the script is run with the flag *--variant production* then C2 and R1 will be loaded.

If the script is run without the *--revision production* flag, then C1 and R1 will be loaded
If the script is run without the *--variant production* flag, then C1 and R1 will be loaded

### Regular Expression Matching

Expand Down

0 comments on commit bf7d800

Please # to comment.