bennymeg / Fabrication-Toolkit

An JLC PCB Fabrication Plugin for KiCad

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Additional layers: can't select user-defined layers

TheColorman opened this issue · comments

When exporting using Fabrication Toolkit, we have the ability to write the names of additional layers to be exported, but this doesn't include any user defined layers, e.g. User.[0-9]. It seems the layers you can use are hardcoded here:

plotPlan = [
("F.Cu", pcbnew.F_Cu, "Top Layer"),
("B.Cu", pcbnew.B_Cu, "Bottom Layer"),
("In1.Cu", pcbnew.In1_Cu, "Internal plane 1"),
("In2.Cu", pcbnew.In2_Cu, "Internal plane 2"),
("In3.Cu", pcbnew.In3_Cu, "Internal plane 3"),
("In4.Cu", pcbnew.In4_Cu, "Internal plane 4"),
("In5.Cu", pcbnew.In5_Cu, "Internal plane 5"),
("In6.Cu", pcbnew.In6_Cu, "Internal plane 6"),
("In7.Cu", pcbnew.In7_Cu, "Internal plane 7"),
("In8.Cu", pcbnew.In8_Cu, "Internal plane 8"),
("In9.Cu", pcbnew.In9_Cu, "Internal plane 9"),
("In10.Cu", pcbnew.In10_Cu, "Internal plane 10"),
("In11.Cu", pcbnew.In11_Cu, "Internal plane 11"),
("In12.Cu", pcbnew.In12_Cu, "Internal plane 12"),
("In13.Cu", pcbnew.In13_Cu, "Internal plane 13"),
("In14.Cu", pcbnew.In14_Cu, "Internal plane 14"),
("In15.Cu", pcbnew.In15_Cu, "Internal plane 15"),
("In16.Cu", pcbnew.In16_Cu, "Internal plane 16"),
("In17.Cu", pcbnew.In17_Cu, "Internal plane 17"),
("In18.Cu", pcbnew.In18_Cu, "Internal plane 18"),
("In19.Cu", pcbnew.In19_Cu, "Internal plane 19"),
("In20.Cu", pcbnew.In20_Cu, "Internal plane 20"),
("In21.Cu", pcbnew.In21_Cu, "Internal plane 21"),
("In22.Cu", pcbnew.In22_Cu, "Internal plane 22"),
("In23.Cu", pcbnew.In23_Cu, "Internal plane 23"),
("In24.Cu", pcbnew.In24_Cu, "Internal plane 24"),
("In25.Cu", pcbnew.In25_Cu, "Internal plane 25"),
("In26.Cu", pcbnew.In26_Cu, "Internal plane 26"),
("In27.Cu", pcbnew.In27_Cu, "Internal plane 27"),
("In28.Cu", pcbnew.In28_Cu, "Internal plane 28"),
("In29.Cu", pcbnew.In29_Cu, "Internal plane 29"),
("In30.Cu", pcbnew.In30_Cu, "Internal plane 30"),
("F.SilkS", pcbnew.F_SilkS, "Top Silkscreen"),
("B.SilkS", pcbnew.B_SilkS, "Bottom Silkscreen"),
("F.Mask", pcbnew.F_Mask, "Top Soldermask"),
("B.Mask", pcbnew.B_Mask, "Bottom Soldermask"),
("F.Paste", pcbnew.F_Paste, "Top Paste (Stencil)"),
("B.Paste", pcbnew.B_Paste, "Bottom Paste (Stencil)"),
("Edge.Cuts", pcbnew.Edge_Cuts, "Board Outline"),
("User.Comments", pcbnew.Cmts_User, "User Comments")
]

I suggest using a way to dynamically get the enabled layers, such as

layers = []
i = pcbnew.PCBNEW_LAYER_ID_START
while i < pcbnew.PCBNEW_LAYER_ID_START + pcbnew.PCB_LAYER_ID_COUNT:
    layer_std_name = pcbnew.BOARD.GetStandardLayerName(i)
    layer_name = pcbnew.BOARD.GetLayerName(board, i)

    layers.append((layer_std_name, i, layer_name))
    i += 1

Adapted from Board2Pdf.

Additionally, the additional layers input box seems to support a list of comma-separated layer names.

extra_layers = [element.strip() for element in extra_layers.strip().split(',') if element.strip()]

This isn't very clear to the user, especially as the autocomplete doesn't acknowledge attempts at adding more than one layer, so I feel like some type hint would be useful.

I'm working on a PR to address these issues, but I'd like to hear some feedback about it here first.

Sounds good.
Regarding the autocomplete, I agree, I could not make it work properly for more than one layer, and the UI is quite limited and could not make it look nice, so I opted to ignore it.
If you could add it properly, I'm all for it.

I've opened PR #152 that makes the autocomplete list dynamically generated. I tried to play around with having a list of layers underneath the text box that you could add/remove from, but couldn't get anything that looked nice, so for now I've just updated the textbox hint.

Thank you!