Environment Variable Substitution

Is there a way to substitute the last file saved date, or an environment variable into a text property?
I want to document when that file was saved when it ships out to fab.
Something like:
BoardName, Rev:${ENV:MY_DATESTAMP_ENVIRONMENT_VARIABLE}

Kicad’s Text Variable feature is good for static text but, for Real Time & Date, well, that would require cleverness…

However, you can use a Plugin and/or the Python Console along with Text placed into PCB.

Example below shows some static text and a Time&Date static text that gets replaced with Real Time&Date upon a Button-Click.

If interested in Plugins, there are plenty of them posted and good info on making plugins…

Here’s a snippet of Time&Date code showing the use of datetime.now.
But, it won’t work with the current Kicad text variable-ability or in Schematic.

txt = re.sub("$Crap1$Crap2", “$TnD$”, draw.GetText())
if txt == “$TnD$”:
now = datetime.datetime.now()
draw.SetText(str(now))

ADDED: You would be able to place various static texts that get updated upon button click. And, could have a Text-Field entry in a Pop-up panel… thus, could have multiple texts for revision dates and reasons/comments…

Thanks for the reply.
I don’t actually require that the displayed text be updated in real time. Last save date is really what I’m after so I can know what version of the file matches to the board I’m holding in my hand. Any solutions that get close to this, like during a screen redraw. Opening the application event may be a little too coarse, but I’d take that in a heartbeat.

I only found about 40 plugins. Is there another source? When I get some time, I may look into writing a plugin.

The Settings for the Page/Title block (Icon below) has a Date field that populates the Date in Schematic/PCB. It doesn’t update unless User clicks it. Thus, the last date remains intact until/unless User wants to change it.

My demo of clicking/placing-current date/other is only to show what can be done with a plugin (or via Python console)…

Many plugins on Git-Hub

Screen Shot 2023-01-06 at 06.25.32

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