"Programatically" setting Solder resist colour

Hi folks,

I’m working on a project that has two variants one with a selection of “No fit” components. To make an obvious difference I have requested to make each of the variants have a different colour (solder resist colour). This is trivial, just set the Solder (Resist) Mask colour in the Board setup . . .

My question is this; is it possible to do this programmatically so that when I choose my Variant (using KiVar) I can get the board to change colour automatically ?

Perhaps I can do it with a custom DRC rule ? so if “X” is set one way make the colour Green, if set the other way make the colour Blue ? and then use KiVar to set “X” . . . it’s not the end of the world if I can’t do this it just helps eliminate one possible error if I can automate it.

From the KiVar github page: " KiVar is a tool for KiCad PCB Assembly Variant selection, provided as platform-independent…"

You may already be familiar with Create a PCB assembly variant system (lp:#1767218) (#2131) · Issues · KiCad / KiCad Source Code / kicad · GitLab, where I did some research and thinking through, and concluded that a board variant is very much different thing than assembly variant. Your use case is interesting and worthy of a wish in wishlist. As far as I know, nobody has created an issue even for generic “board variants”, let alone your use case.

Yup, this is what I’m using it for . . . but just trying to leverage it for some added functionality.

If the Solder resist colour is not exposed to be controlled programmatically them I’m at a dead end . . . and can fall back to doing this manually. Just wanted to check with those in the know before giving up hope.

Well I found this . . .

image

but no idea how to be able to use it.

Here’s the Scoop… Based on v7

First: The ‘PCB Setup’ info will be in the PCB file. BUT, by Default, it will NOT be there Until you make a Change to the Mask Color in the PCB-Setup.

Once you make the Color Change in setup, the Info will show in the PCB File

Now, you can change the colors using Python, Text-Editor or any Code-language you prefer… and, can do it from the CLI interface…

Example:
After setting as stated above, this is the Info that shows and all you need to do is Edit the RGB color.

(setup
(stackup
(layer “F.SilkS” (type “Top Silk Screen”))
(layer “F.Paste” (type “Top Solder Paste”))
(layer “F.Mask” (type “Top Solder Mask”) (color “#0000849E) (thickness 0.01))
(layer “F.Cu” (type “copper”) (thickness 0.035))
(layer “dielectric 1” (type “core”) (thickness 1.51) (material “FR4”) (epsilon_r 4.5) (loss_tangent 0.02))
(layer “B.Cu” (type “copper”) (thickness 0.035))
(layer “B.Mask” (type “Bottom Solder Mask”) (color “#FFFF0052) (thickness 0.01))
(layer “B.Paste” (type “Bottom Solder Paste”))
(layer “B.SilkS” (type “Bottom Silk Screen”))
(copper_finish “None”)
(dielectric_constraints no)
)

3 Likes