Generic mechanism for text replacement variables
Description
Would it be possible to get a generic mechanism in KiCad to use text replacement (substitution) variables, like path variables are now used in file paths?
Example: I have a project version. Now I have to write it and keep it up to date in several places. Let's say I want to have it in:
- Schematic page settings
- Layout page settings
- Gerber and other print output names
- In the layout in both surface layers (silk or other)
I's quite tedious to change it, something will surely be forgotten.
Solution:
- Add global variable system, like path variables are now.
- Add a generic system for text replacements, like with library path variables or like numbers are evaluated.
- In every text field these variables can be used and replaced with the given value.
Solution example:
- Add a global variable REVNUM = 1.0.
- Use it in page settings:
- Use it in layout:
- Use it in gerber output:
Somewhere else a mechanism for parametrized hierarchical sheet has been proposed. Maybe this could be used for that, too. The variables could be defined in several levels, for example:
- Global in KiCad (per user)
- Global in project
- Each application in the project
- Each hierarchical sheet instance
- Maybe other possibilities
That would need an overriding mechanism. I'll try to find the relevant report or other place where this was proposed.
The variable name text to be replaced should be in most cases be persistent and that can be difficult to implement. Path variables are persistent in texts (the variable names are saved in the text but replaced only when used runtime). Texts for number evaluations, on the other hand, persist only for the UI element while it's open (like "2+2" stays "2+2" only when the dialog where it is stays open).
KiCad Version
Application: KiCad
Version: (5.99.0-764-gf1fcf3f1d), release build
Libraries:
wxWidgets 3.0.4
libcurl/7.66.0 OpenSSL/1.1.1d (Schannel) zlib/1.2.11 brotli/1.0.7 libidn2/2.2.0 libpsl/0.21.0 (+libidn2/2.1.1) nghttp2/1.39.2
Platform: Windows 7 (build 7601, Service Pack 1), 64-bit edition, 64 bit, Little endian, wxMSW
Build Info:
Build date: Jan 16 2020 22:17:42
wxWidgets: 3.0.4 (wchar_t,wx containers,compatible with 2.8)
Boost: 1.71.0
OpenCASCADE Community Edition: 6.9.1
Curl: 7.66.0
Compiler: GCC 9.2.0 with C++ ABI 1013
Build settings:
KICAD_SCRIPTING=ON
KICAD_SCRIPTING_MODULES=ON
KICAD_SCRIPTING_PYTHON3=OFF
KICAD_SCRIPTING_WXPYTHON=ON
KICAD_SCRIPTING_WXPYTHON_PHOENIX=OFF
KICAD_SCRIPTING_ACTION_MENU=ON
BUILD_GITHUB_PLUGIN=ON
KICAD_USE_OCE=ON
KICAD_USE_OCC=OFF
KICAD_SPICE=ON


