You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

143 lines
5.5 KiB

  1. # 1 - Full documentation
  2. The Eeschema documentation (*eeschema.html*) describes this intermediate netlist and gives examples(chapter ***creating customized netlists and bom files***).
  3. # 2 - The intermediate Netlist File
  4. BOM files (and netlist files) can be created from an *Intermediate netlist file* created by Eeschema.
  5. This file uses XML syntax and is called the intermediate netlist. The intermediate netlist includes a large amount of data about your board and because of this, it can be used with post-processing to create a BOM or other reports.
  6. Depending on the output (BOM or netlist), different subsets of the complete Intermediate Netlist file will be used in the post-processing.
  7. # 3 - Conversion to a new format
  8. By applying a post-processing filter to the Intermediate netlist file you can generate foreign netlist files as well as BOM files. Because this conversion is a text to text transformation, this post-processing filter can be written using *Python*, *XSLT*, or any other tool capable of taking XML as input.
  9. XSLT itself is a XML language suitable for XML transformations. There is a free program called `xsltproc` that you can download and install. The `xsltproc` program can be used to read the Intermediate XML netlist input file, apply a style-sheet to transform the input, and save the results in an output file. Use of `xsltproc` requires a style-sheet file using XSLT conventions. The full conversion process is handled by Eeschema, after it is configured once to run `xsltproc` in a specific way.
  10. A Python script is somewhat more easy to create.
  11. # 4 - Initialization of the dialog window
  12. You should add a new plugin (a script) in the plugin list by clicking on the Add Plugin button.
  13. ## 4.1 - Plugin Configuration Parameters
  14. The Eeschema plug-in configuration dialog requires the following information:
  15. * The title: for instance, the name of the netlist format.
  16. * The command line to launch the converter (usually a script).
  17. ***Note (Windows only):***
  18. *By default, the command line runs with hidden console window and output is redirected to "Plugin info" field. To show the window of the running command, set the checkbox "Show console window".*
  19. Once you click on the generate button the following will happen:
  20. 1. Eeschema creates an intermediate netlist file \*.xml, for instance `test.xml`.
  21. 2. Eeschema runs the script from the command line to create the final output file.
  22. ## 4.2 - Generate netlist files with the command line
  23. Assuming we are using the program `xsltproc.exe` to apply the sheet style to the intermediate file, `xsltproc.exe` is executed with the following command.
  24. ```
  25. xsltproc.exe -o <output filename> <style-sheet filename> <input XML file to convert>
  26. ```
  27. On Windows the command line is the following.
  28. ```
  29. f:/kicad/bin/xsltproc.exe -o "%O" f:/kicad/bin/plugins/myconverter.xsl "%I"
  30. ```
  31. On Linux the command becomes as following.
  32. ```
  33. xsltproc -o "%O" /usr/local/kicad/bin/plugins/myconverter .xsl "%I"
  34. ```
  35. where `myconverter.xsl` is the style-sheet that you are applying.
  36. Do not forget the double quotes around the file names, this allows them to have spaces after the substitution by Eeschema.
  37. If a Python script is used, the command line is something like (depending on the Python script):
  38. ```
  39. python f:/kicad/bin/plugins/bom-in-python/myconverter.py "%I" "%O"
  40. ```
  41. or
  42. ```
  43. python /usr/local/kicad/bin/plugins/bom-in-python/myconverter .xsl "%I" "%O"
  44. ```
  45. The command line format accepts parameters for filenames. The supported formatting parameters are:
  46. * `%B`: base filename of selected output file, minus path and extension.
  47. * `%P`: project directory, without name and without trailing '/'.
  48. * `%I`: complete filename and path of the temporary input file
  49. (the intermediate net file).
  50. * `%O`: complete filename and path (but without extension) of the user
  51. chosen output file.
  52. `%I` will be replaced by the actual intermediate file name (usually the full root sheet filename with extension ".xml").
  53. `%O` will be replaced by the actual output file name (the full root sheet filename minus extension).
  54. `%B` will be replaced by the actual output short file name (the short root sheet filename minus extension).
  55. `%P` will be replaced by the actual current project path.
  56. ## 4.3 - Command line format:
  57. ### 4.3.1 - Remark:
  58. Most of time, the created file must have an extension, depending on its type.
  59. Therefore you have to add to the option ***%O*** the right file extension.
  60. For instance:
  61. * **%O.csv** to create a .csv file (comma separated value file).
  62. * **%O.htm** to create a .html file.
  63. * **%O.bom** to create a .bom file.
  64. ### 4.3.2 Example for xsltproc:
  65. The command line format for xsltproc is the following:
  66. ```
  67. <path of xsltproc> xsltproc <xsltproc parameters>
  68. ```
  69. On Windows:
  70. ```
  71. f:/kicad/bin/xsltproc.exe -o "%O.bom" f:/kicad/bin/plugins/netlist_form_pads-pcb.xsl "%I"
  72. ```
  73. On Linux:
  74. ```
  75. xsltproc -o "%O.bom" /usr/local/kicad/bin/plugins/netlist_form_pads-pcb.xsl "%I"
  76. ```
  77. The above examples assume `xsltproc` is installed on your PC under Windows and xsl files located in `<path_to_kicad>/kicad/bin/plugins/`.
  78. ### 4.3.3 Example for Python scripts:
  79. Assuming python is installed on your PC, and python scripts are located in
  80. `<path_to_kicad>/kicad/bin/plugins/bom-in-python/`,
  81. the command line format for python is something like:
  82. ```
  83. python <script file name> <input filename> <output filename>
  84. ```
  85. On Windows:
  86. ```
  87. python.exe f:/kicad/bin/plugins/bom-in-python/my_python_script.py "%I" "%O.html"
  88. ```
  89. On Linux:
  90. ```
  91. python /usr/local/kicad/bin/plugins/bom-in-python/my_python_script.py "%I" "%O.csv"
  92. ```