Text variable

Hi,
on kicad 8.0.7 on windows.
I have one schematic variable for my board version.
And I use it in some Text objet in the layout to display the version number on the silkscreen

When I update the schematic variable to a new number, the change is not reflected in the layout.
If I do an update pcb from schematic, the variable is stil not updated.

I end up having to close kicad completly (including the project), and after that the text is updated in my layout.

Am I missing something to force the update ?

1 Like

I also use text variables in my projects and I get the same behavior as you.
A bit frustrating, but for now I close and re-open KiCAD as a solution.
Perhaps we should fill the bug report.

If I understand correctly . . . I do something similar but differently . . . I use the variable to update a field in a symbol and then the symbol is used to update the footprint (and silkscreen). At least thats what I think I am doing . . . have my head in Solidworks right now so not at liberty to check . . . if what I have written doesn’t help I’ll check back a little later and check what I’m actually doing in KiCad.

I did log a bug report in the past, but It was closed.
So I guess my explanation was not clear enough

Well it was closed because it was seen as a repetition of this bug report, that is still open BTW:

1 Like

you are right.
But reading the discussion around it does not show a solution.

In fact, I understand the discussion about not wanting to do an automatic update of the variable and the possible consequence.
But If I do a update pcb from schematic, the the variables should be updated, as I’m doing an actual action to update my PCB

May be someone have another solution to do what I want.

I want one place (an only one), where I can put a version number for my PCB. And I want to be able to display this version number a different places (so more than one) on my PCB.

And usually I want to update this version string when I’m done working on the PCB.

Text variables seem the way to go. but they don’t update when they should.

Hi, you are right. Using a symbol and a footprint to hold my version info is probably the way to go.
I’ll give that a try

2 Likes

What do you mean by schematic variable? How have you created it?

In the schematic editor, you go in File->schematic setup->text variable

Then I use it in a text box in the PCB (using ${myversion} )

Hi!
I have defined ${MYREVISION} in eeschema File->SchematicSetup → Project → TextVariables.
I use it in my (company) title block and also on PCB silkscreen to show the version info.

When I change the value of the variable in eeschema it is updated on the title block and in a text field in my schematic immediately.
Also there is a star (*) in front of the file name in the top line meaning that the schematic is unsaved.

When I change to pcbNew (ALT-TAB) the value in the title block was also updated.
But the silkscreen text was not. Pressing refresh did not change the value.
Even if the value has changed in the title block, there is no (*) indication on the file name that the file has changed!
Closing pcbNew does not prompt for save and restarting gives the same result (Revision numbers differ).

Going to pcbNew File → BoardSetup and pressing OK gives me the indication that the file has to be saved.
Saving and restarting pcbNew finally gives me the correct version both in frame and silkscreen text.

Actually the text variable is stored in
*.kicad_pro

 "text_variables": {
...
    "MYREVISION": "6",
...

it is just used in
*.kicad_sch

(title_block
...
		(rev "${MYREVISION}")
...
(text "${MYREVISION}"
...

in *.kicad_pcb

(title_block
...
		(rev "${MYREVISION}")
...
(property "MYREVISION" "5")
...
(gr_text "${MYREVISION}"

the variable ist used for the title block, which prints out correctly.
But there is also a separate property assignment that needs to be updated.
The silkscreen text command is behind the proporty statement so it uses the outdated version info.

I have no clue why pcbNew has this separate property statement. This question has to be addressed to the developers.

I am using

Application: KiCad PCB Editor x64 on x64
Version: 8.0.7, release build
2 Likes

Not a developer, but I believe variables are cached in the board file for fabrication reasons. Many fabs accept board files instead of gerbers. When you submit a board to such a fab, you submit just the .kicad_pcb and not the project file. If the board file didn’t cache the text variables, variables would be unresolved in the manufactured pcb.

1 Like

Probably should have the facility for separate schematic and pcb revisions - you might update the schematic with a different component or value but retain the same layout, or you might change a footprint in the pcb without altering the component for instance if there were manufacturing issues so there are good reasons for these not to be the same. There should be the facility for Schematic rev A, B, C etc and Board Rev 1, 2, 3 etc as well as an overall revision option eg from a SCM where you could also employ tags to achieve the same effect.

2 Likes

Hi @bertrand_meneroud
I totally get your point and have updated the bug report in the KiCad repo

Actually text variables are updated in pcbnew. When you go to File->BoardSetup → Project → TextVariables you will find the latest values. Pressing OK, when leaving this dialog will update the values in the PCB.

But this is still a weird behavior.

1 Like

The build in ${REVISION} variable does exactly this:
It resides in the context of either schematic or pcbnew.
It can be printed out by text field everywhere in schematic or pcbnew and will return the value that has been set in the corresponding Page Stettings dialog.

But this variable can only be set in the revision box.

I had struggled with this and decided to override it by putting ${MYREVISION} in both revision fields in eeschema and pcbnew.

My point is: The user has intentionally changed the value of the text variable in eeschema.
In the schematic the * in front of the file name is set
grafik

So how about also setting the file save ‘*’ and updating the variables in pcbnew after a variable has been changed in eeschema? This way the user is prompted to save the PCB when closing pcbnew. If he declines the cached variables will be kept.

1 Like

Yes. REVISION is a special case because it has been in KiCad even before the current string replacement system. One possible solution is to put ${REVISION} to the Revision field in the page properties in both the schematic and pcb editors after defining a project variable of the same name.

I did not dare to put ${REVISION} into the Revision field.
Ended up to to put ${MYREVISION} there to avoid confusion.
Besides the caching this works fine for me.

I had put Revision is ${REVISION} in the title entry box for testing and was surprised that it would not expand. So I had already assumed some legacy code…

1 Like