Are all layers supported by the kicad-cli pcb export?

Hello,

I’m trying to export User.Drawings layer, but I got “Invalid layer name” are all layers supported?

kicad-cli pcb export pdf -o fig/pcb_drawing.pdf ./light_ring_3535x6.kicad_pcb -l User.Drawings
Invalid layer name "User.Drawings"
At least one or more layers must be specified

Thanks

Is this a blank between ‘User’ and the dot?

I don’t thing so, this is the output with the blank:

kicad-cli pcb export pdf -o fig/pcb_drawing.pdf ./light_ring_3535x6.kicad_pcb -l User .Drawings
Maximum number of positional arguments exceeded
Usage: pdf [-h] [--output VAR] [--layers VAR] [--exclude-refdes] [--exclude-value] 
[--include-border-title] [--black-and-white] [--theme VAR] input

Positional arguments:
  input                         Input file 

Optional arguments:
  -h, --help                    shows help message and exits 
  -o, --output                  Output file name [default: ""]
  -l, --layers                  Comma separated list of untranslated layer names to
 include such as F.Cu,B.Cu [default: ""]
  --erd, --exclude-refdes       Exclude the reference designator text 
  --ev, --exclude-value         Exclude the value text 
  --ibt, --include-border-title Include the border and title block 
  --black-and-white             Black and white only 
  -t, --theme                   Color theme to use (will default to pcbnew settings
) [default: ""]

I find the help very minimal:

paul@cezanne:~$ kicad-cli -h
Usage: kicad-cli [-h] {fp,pcb,sch,sym,version}

Optional arguments:
  -v, --version	prints version information and exits 
  -h, --help   	shows help message and exits 

Subcommands:
  fp            
  pcb           
  sch           
  sym           
  version 

It does not even mention the “export” thing, and there is no man page installed either.

However, a quick test shows that exporting F.Cu works, while User.Drawings gives an error message.

paul@cezanne:~/projects/kicad/mumar_base_stm32_V5.1$ kicad-cli pcb export pdf mumar_base_stm32.kicad_pcb -l F.Cu
Loading board
paul@cezanne:~/projects/kicad/mumar_base_stm32_V5.1$ kicad-cli pcb export pdf  mumar_base_stm32.kicad_pcb -l User.Drawings
Invalid layer name "User.Drawings"
At least one or more layers must be specified

Each command has its own help:

Usage: kicad-cli [-h] {fp,pcb,sch,sym,version}

Optional arguments:
  -v, --version	prints version information and exits 
  -h, --help   	shows help message and exits 

Subcommands:
  fp            
  pcb           
  sch           
  sym           
  version       
~ 
❯ kicad-cli pcb -h
Usage: pcb [-h] {export}

Optional arguments:
  -h, --help	shows help message and exits 

Subcommands:
  export     
~ 
❯ kicad-cli pcb export -h
Usage: export [-h] {drill,dxf,gerber,gerbers,pdf,pos,step,svg}

Optional arguments:
  -h, --help	shows help message and exits 

Subcommands:
  drill      
  dxf        
  gerber     
  gerbers    
  pdf        
  pos        Generate Position File
  step       
  svg        
~ 
❯ kicad-cli pcb export pdf -h
input: 1 argument(s) expected. 0 provided.
Usage: pdf [-h] [--output VAR] [--layers VAR] [--exclude-refdes] [--exclude-value] [--include-border-title] [--black-and-white] [--theme VAR] input

Positional arguments:
  input                        	Input file 

Optional arguments:
  -h, --help                   	shows help message and exits 
  -o, --output                 	Output file name [default: ""]
  -l, --layers                 	Comma separated list of untranslated layer names to include such as F.Cu,B.Cu [default: ""]
  --erd, --exclude-refdes      	Exclude the reference designator text 
  --ev, --exclude-value        	Exclude the value text 
  --ibt, --include-border-title	Include the border and title block 
  --black-and-white            	Black and white only 
  -t, --theme                  	Color theme to use (will default to pcbnew settings) [default: ""]
~ 

Also you can put there * and the it will export all layers (didn’t check whether it is actually all):

kicad-cli pcb export pdf -o fig/pcb_drawing.pdf ./light_ring_3535x6.kicad_pcb -l "*"
Loading board

Also this will export dimensions in inches rather than millimetres.

But can’t specify User.Drawings, User.Comments and probably more…

1 Like

Ok, digging into source code revealed that the name are probably defined differently that displayed in kicad app.

User.Drawings → Dwgs.User
User.Comments → Cmts.User
User.Eco1 → Eco1.User
User.Eco2 → Eco2.User

Here is the header that probably defines the layer IDs and the names can be infer from there:

4 Likes

I can confirm that exporting “Dwgs.User” works, while the layer is called “User.Drawings” in the KiCad project.

I also had a look at gitlab and apparently there is no issue for this. I already started creating an issue for it, but aborted. I guess I’ll leave it to you first if you want to do this.

Unfortunately the wildcard * layer selector does not work and I find I have to specify each layer explicitly. This is unfortunate and, if wildcard selection did work, it might address this problem ….

I noticed this when a Kicad 5 project was converted to Kicad 6,

This table was generated by my KiRI tool.
Here I have selected 2 commits where one is using the Kicad 5 project and the other is Kicad 6

See some lines with 2 layer names that correspond to each Kicad version.

It would be nice to have a flag to use the layer ID instead of the name when exporting layers, then I could export using a for loop easily.

Alternatively, it would be nice to have a way to print the available layers in the kicad_pro file.

So for instance kicad-cli pcb layers board.kicad_pro could export a list of layer names.

1 Like

It works for me, but it has to be surround by quotation marks "*", otherwise is interpreted by shell as wildcard for files…

I have started an Issue: kicad-cli: pcb export pdf accept different layer names than displayed in gui (#14455) · Issues · KiCad / KiCad Source Code / kicad · GitLab

2 Likes

Thanks, I’ll try when I’m back from holiday.

Apparently JP already fixed, it should appear in the test build in the next day, it would be cool it you could check that everything works as expected.

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