pcb-rnd knowledge pool


Configuring export_xy to output a custom csv

xy_template by Tibor 'Igor2' Palinkas on 2018-04-19

Tags: howto, xy, template, csv, export

node source



Abstract: Plugin export_xy writes the output file using a named template. The template is one of multiple configured templates. The configuration is coming from the normal pcb-rnd configuration system. This howto describes creating a new, custom csv template as an user configuration.


When an export_xy template works

The export_xy plugin is a simple loop that can print a block of textual information for each subcircuit and/or for each subcircuit terminal. It can also print a text block header. If an output format is structured that way, configuring a template for export_xy will make pcb-rnd able to output in that format. Typical examples of such formats:

How does templating work

Each format has an user assigned ID (which is the short name of the format). There is a list of strings in the config tree under plugins/export_xy/templates; each item is named as ID . something where something is:

Templates are text strings; they are printed as is, keeping all newlines and whitespace. Portions in between % signs are substituted, depending on the context.

Custom CVS export example

The following example file should be copied into ~/.pcb-rnd/export_xy.conf (or relevant section copied directly into ~/.pcb-rnd/pcb-conf.lht or the project file, under the plugins subdir).

li:pcb-rnd-conf-v1 {
 ha:append {
  ha:plugins {
   ha:export_xy {
    li:templates {

myparts.name = {my parts CSV}
myparts.hdr = {# My own part CSV format
# refdes,value
myparts.subc = {%subc.refdes%,"%subc.value%"


The ID of the new format is "myparts", the long name is "my parts CSV". It prints one line per subcircuit, with the refdes and the value.

The indentation of the lihata nodes had to be suspended because any space or tab written within the {} of the template would end up in the output.

Note that the second line of the config file is ha:append ; this means the new template strings will be appended at the end of the existing list of templates. This has two consequences: on the UI, the new template is located after the default templates (read e.g. from the system config); and if there is an ID collision (two templates using the same ID) the first match is picked, so our new config is a weak template that won't override existing templates even on template ID match. This can be changed by using ha:prepend instead.