Skip to content

Conversation

@nguyen-v
Copy link

@nguyen-v nguyen-v commented Dec 22, 2024

This PR adds a new preflight Include Text, which takes as an input TXT file(s) from an output, and adds it to the PCB. This useful for adding fabrication/assembly notes to the PCB which can be generated by the report output.
On the PCB, either a text or textbox object has to be added to a group called kibot_txt_<output_name>. The text inside the object is then modified by the preflight.

@set-soft
Copy link
Member

What's the advantage of this over just using set_text_variable?

@nguyen-v
Copy link
Author

nguyen-v commented Dec 23, 2024

What's the advantage of this over just using set_text_variable?

Set text variables (and in general kicad variable expansions) doesn't allow newlines. I actually use set_text_variables for changelogs in the schematic (synchronised with CHANGELOG.md), but to get new lines I need to have a custom script that pads with spaces and invisible characters (\u2003), knowing in advance the width of the textbox
https://github.com/nguyen-v/amulet_controller_kibot/blob/5b4d8c42dca3ab097dbbd1685fc3276eb7fc044d/scripts/get_changelog.py

Actually, it would be very useful to have something similar to this preflight for the schematic, so as not to have to resort to the hacky solution I had to do

@set-soft
Copy link
Member

Set text variables (and in general kicad variable expansions) doesn't allow newlines.

Why? I tried this:

kibot:
  version: 1

preflight:
  set_text_variables:
    - name: PRUEBITA
      command: 'cat g1.sh'

outputs:
  - name: 'print_sch'
    comment: "Print schematic (PDF)"
    type: pdf_sch_print
    dir: .
    options:
      output: Schematic.pdf

With the g1.sh from the repo and an schematic with a text containing ${PRUEBITA} and got:

image

Same for the PCB:

image

Or from KiBot:

image

@nguyen-v
Copy link
Author

nguyen-v commented Dec 24, 2024

You're right, looks like I was doing something wrong in my tests, feel free to close and discard this PR. Is there a way to choose an output with the set_text_variables?

Here amulet_controller-fabrication_notes.txt is generated from a report output. With variants, the name of the file would be different (%f-fabrication_notes%v.txt), is it possible to expand %f, %v and so on in the command?

    # Fabrication notes
    - variable: 'FABRICATION_NOTES'
      command: 'cat Manufacturing/Fabrication/amulet_controller-fabrication_notes.txt' # %f-fabrication_notes%v.txt

If this is not supported yet, maybe have something like:

    # Fabrication notes
    - variable: 'FABRICATION_NOTES'
      output: <output_name>[<index>]
@set-soft
Copy link
Member

Ok, the above patch adds an option to perform expansions in the command.

@set-soft set-soft closed this Dec 26, 2024
@nguyen-v
Copy link
Author

Thanks!

nguyen-v pushed a commit to nguyen-v/KiBot that referenced this pull request Dec 26, 2024
@nguyen-v nguyen-v deleted the pre_include_text branch December 27, 2024 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants