Variable substitution does not work reliably

You should be able to upgrade seamlessly to the latest stable release 6.0.8
As always, backup your projects first

I still have the same issue, in the silk screen text, one of the variables is evaluated properly, the rest aren’t. So, I can’t even test, whether the problem is that there are multiply substitutions in the same expression.

Also, fields in the title block are not evaluated at all.

I attach my kicad_pcb file here.
test1.kicad_pcb (3.1 KB)

Application: KiCad PCB Editor (64-bit)

Version: (6.0.8), release build

Libraries:

  wxWidgets 3.1.7

  libcurl/7.83.1-DEV Schannel zlib/1.2.12

Platform: Windows 11 (build 22000), 64-bit edition, 64 bit, Little endian, wxMSW

Build Info:

  Date: Sep 29 2022 00:21:26

  wxWidgets: 3.1.7 (wchar_t,wx containers)

  Boost: 1.79.0

  OCC: 7.6.0

  Curl: 7.83.1-DEV

  ngspice: 37

  Compiler: Visual C++ 1929 without C++ ABI

Build settings:

  KICAD_USE_OCC=ON

  KICAD_SPICE=ON

Yes, I think this is the same issue. However, I am a bit confused by what you say on gitlab: the board file should contain everything that’s required to generate the fabrication outputs. Otherwise, PCB houses’ support for KiCAD files is meaningless. Having access to the source allows manufacturers to extract relevant information (e.g., the size of the boad etc.), or check the design rules on the fly, while some can’t do that based on the gerber files. So, it is not just that I want to save two mouse clicks when exporting the gerber files (although, since I don’t actually need the gerber files, that does create clutter), it does have added value.

That being the case, I really wonder, whether such data should be moved to the board file. I really don’t understand why the project file should be concerned with PCB design rules. I still maintain that bringing in variable substitution was a brilliant idea, because e.g., if you have the same, version-dependent, label 100 times on a board, then you can have a single source of truth.

1 Like

I didn’t take part on that discussion, and I haven’t tested how this works in v6.99 (the unstable development version, “nightly builds”). Can you test with the nightly builds and tell if your problem has been fixed there? I think that saving vs. not saving the variable data in the pcb file is a feature change, and if in v6.0 they have not been saved in the pcb file, this won’t be fixed in the v6.0.x bugfix releases, only in the feature development version which is now 6.99.

Seems to work fine for me (as long as I believe this feature applies to Only the Project wherein the Variable(s) are defined. (see below…))

Mac OSX Monterey
Kicad 6.0.8

The Text Variable(s) apply to only the Project/PCB/Schematic where they are defined BUT, I could be wrong about that.

On one-hand, it makes sense. On the other-hand, it would be good if the Text-Variable(s) would apply across all projects.

To make them apply across all projects, for me, since v5, I make my own Text-Varibles combined with a Plugin. That only works on the PCB’s (all PCB’s). So, I’m glad to now see this feature in 6.0.8 as it works on both PCB and Schematic (in the project wherein they’re defined).

The downside is that I need to make Text-Variable in each PCB/Schematic. BUT, that has an Easy Solution! Simply setup the Text-Variable(s) in a Template’s PCB and/or Schematic. This works Perfectly Well!

I created several Variables - some specific for PCB, some specific for Schematic and, some Common to both PCB and Schematic.
I did Not place the variables onto the PCB/Schematic until after opening the project thus, I can place whatever I want as needed (knowing they are all defined). Simple!

Anyway, below shows your posted file with your original variables but with my (needed to add) variables in the PCB setup panel. As soon as I set those, your PCB populated with the Text…

ADDED: it makes sense to post this link to my Making Templates. Thus, define the Text-Variable(s) in either the PCB or Schematic. Then, when creating new project with the Template, you need only to place the ${your variable} onto PCB and/or Schematic.

Defined the Variables/Text in the PCB’s setup panel

After defining the Variables, this is the result in your posted PCB

I understand this, but my whole point was that I do not want to re-define the variables. My point was that the file that I posted should work without having to tamper with it. I am fully aware of how I can define the text variables, but you should see

Obvious Error 1.0.0
Infinite Volatility Ltd.

if you open the file that I uploaded. Right away. Without editing anything.

And your example is just as baffling: you don’t define the VERSION variable, yet, you see its value.

You don’t have to redefine the variables if you create them in a template.

Demonstrating that ‘a’ variable will work doesn’t require demonstrating every variable. I did only two of them.

Houdini - I imagine he could magically make it work on PCB/Schematic that are unrelated to the Specific Project where the Variables were defined.

You have to put money in the Bank Account in order to write many checks against the Account.

Thus, in a similar manner, you need to put Variables in an Account for all the PCB/Schematics (related to the same account) to work.

The easiest way to do that is to make a Template that contains All your desired variables. Then, the PCB/Schematics (based on using the Template) will work.

Yes, sorry, in my haste I didn’t pay attention to who was posting where and what.

As for testing this with the nightly build, I would be glad, but I cannot install that side by side with the stable release. Perhaps, what could help here is having nightlies in the snap, or flatpak, because those can be installed in the home directory. But I haven’t found this option.

But version information, almost by definition, cannot be part of the template, can it?

But the variables are actually in the PCB file. They are just not taken into account.

I deleted the Text Variables so there wouldn’t be any text to populate. You can see (in video), No Errors.

In the Template, You can define a list of Variables as long as your arm (so to speak) on either the PCB or Schematic (they use the same info so, only need to do it on one of them (pcb or schematic).
If you don’t place any of the Variables Onto the PCB or Schematic in the Template, they won’t populate until you actually place them onto PCB/Schematic but, you Won’t need to Re-define them - They remain defined in the Template’s PCB/Schematic, ready to be used, meaning, they Will Be Taken Into Account.

EDIT: Think about it - How would Project A know what Project B has defined for Variabes unless Kicad had setup this feature to be a ‘Cross-Project’ tool?
Thus, you (user) can make it a Cross-Project feature by doing it for a Template and using the Template for a New Project… get it!

still_works

I have the feeling that I didn’t explain properly what the problem is: the kicad_pcb file contains the required information. It is just not used, and this leads to errors as described in the gitlab issue. So, given that the information is available, Project A could actually learn what Project B defined by inspecting the contents of the PCB file. But that is probably beside the point. In the OP, I had a single file, and didn’t want to share variables. PCB houses require a single file, the kicad_pcb file, nothing more. Thus, this file should contain everything that is necessary for the fabrication.

And again, version information cannot be part of the template. The solution that you suggest could be used as a workaround in certain cases, but is definitely not how the issue should be solved. If I define variables in a template, then create a project from said template, then everything works, but as soon as I copy the single board file to a new directory, I have the same problem, so the board file cannot be handed over for production.

I guess I’m confused so, I leave it for others to help you…

That said, I have No Problem copying the PCB to a new/other folder, it still works because the variables are defined in the original file and remain defined in the Copied/Pasted files.

Consider just Copy/Paste the Text as needed…

good luck

I just tested, and me neither (have no problem).

  1. Add a project variable in a project.
  2. Use that variable in a pcb file text item.
  3. Copy the file to a new empty folder.
  4. Open the new file with standalone Pcbnew.
  5. The variable is there, resolved as it should.

I tested with both 6.0 and 6.99.

Version: 6.0.7-f9a2dced07~116~ubuntu22.04.1, release build

Version: (6.99.0-3706-gc87a5ff0ab), release build

What is a project variable, as opposed to a text variable defined in PCBNew? Do you mean a variable that comes from a template?

And how does this relate then to the gitlab issue that you linked to? That is only a week old, so 6.0.7 cannot contain the fix for that.

If you define a variable in pcbnew Board Setup, it will be a project variable. You know this already. If there is any confusion, it is caused by something which prevents you seeing a variable as resolved in the board. As I said, it works for me, and I can’t tell why it doesn’t work for you.

Well, I wouldn’t even have noticed, hadn’t it been for the funny-looking boards coming back from the PCB house. Also, the gitlab issue seems to imply that this problem is more widespread than my special case.

I had the same problem problem with boards made by eurocircuits.
They have an online viewer so you can test for the issue

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.