INTI-CMNB / KiBot

KiCad automation utility
GNU Affero General Public License v3.0
552 stars 65 forks source link

[FEATURE] (Quickie) Position Output as XLSX #593

Closed mgritz closed 5 months ago

mgritz commented 6 months ago

Thanks to this awesome project I finally managed to get PCB fabrication data generation almost fully automated via GitLAB CI for the first time in my career! 😎

There is one small addition I would like to propose: I'd like the position output to additionally support XLSX as the output file format similar to the bom output.

Doing the conversion from CSV to XLSX for the position file is the last manual step I need to take. If that is automated as well I can simply upload CI artifacts.

To add a bit of context: I work with several small PCB manufacturers who all like to receive BOM- and Positional-BOM files as XLSX. All of us have to work with a German locale. Excel, obeying the system locale, fails to parse the international de-facto-standard form of CSV files Kibot generates: , is equivalent to a decimal point in German🙄

Alternatively, one could think about an "output" that is capable of calling an arbitrary shell command. I wrote a little script (see attached) for the conversion using openpyxl - which conveniently ignores the German locale. However I assume this to be beyond the scope of Kibot.

csv_to_xlsx.py.txt

set-soft commented 6 months ago

Hi @mgritz !

I think you can just try something like this:

kibot:
  version: 1

outputs:
  - name: xyrs_xlsx
    comment: "Pick and place file, XYRS style, XLSX format"
    type: bom
    dir: XYRS
    options:
      pre_transform: ['_kicost_rename', '_rot_footprint']
      dnf_filter: _only_smd
      output: '%f-%i%I%v_XYRS.%x'
      units: millimeters
      group_fields: []
      sort_style: ref
      use_aux_axis_as_origin: true
      ignore_dnf: false
      footprint_populate_values: '0,1'
      footprint_type_values: '1,2,0'
      format: XLSX
      columns:
        - field: References
          name: Designator
        - field: Footprint X
          name: X-Loc
        - field: Footprint Y
          name: Y-Loc
        - field: Footprint Rot
          name: Rotation
        - field: Footprint Side
          name: Side
        - field: Footprint Type
          name: Type
        - field: Footprint X-Size
          name: X-Size
        - field: Footprint Y-Size
          name: Y-Size
        - field: Value
        - field: Footprint
        - field: Footprint Populate
          name: Populate
        - field: MPN

Currently the BoM output can include position data, in order to generate XYRS files, so you should be able to generate position files in XLSX format.