Commit ef20a2bb authored by Ronald Sousa's avatar Ronald Sousa

- Renamed tb2 to tb

- corrected the code that violated the code policy. i.e. added the extra space to make the code more readable
- Restored bom2csv.xsl to its original form 
- Added bom_with_title_block_2_csv.xsl which has the new BOM generator.
parent 8a916a61
...@@ -670,16 +670,16 @@ XNODE* NETLIST_EXPORT_TOOL::makeGenericDesignHeader() ...@@ -670,16 +670,16 @@ XNODE* NETLIST_EXPORT_TOOL::makeGenericDesignHeader()
if( screen != NULL ) if( screen != NULL )
{ {
TITLE_BLOCK tb2 = screen->GetTitleBlock(); TITLE_BLOCK tb = screen->GetTitleBlock();
xdesign->AddChild( node( wxT( "title" ), tb2.GetTitle() )); xdesign->AddChild( node( wxT( "title" ), tb.GetTitle() ) );
xdesign->AddChild( node( wxT( "company" ), tb2.GetCompany())); xdesign->AddChild( node( wxT( "company" ), tb.GetCompany() ) );
xdesign->AddChild( node( wxT( "revision" ), tb2.GetRevision())); xdesign->AddChild( node( wxT( "revision" ), tb.GetRevision() ) );
xdesign->AddChild( node( wxT( "issueDate" ), tb2.GetDate())); xdesign->AddChild( node( wxT( "issueDate" ), tb.GetDate() ) );
xdesign->AddChild( node( wxT( "comment1" ), tb2.GetComment1())); xdesign->AddChild( node( wxT( "comment1" ), tb.GetComment1() ) );
xdesign->AddChild( node( wxT( "comment2" ), tb2.GetComment2())); xdesign->AddChild( node( wxT( "comment2" ), tb.GetComment2() ) );
xdesign->AddChild( node( wxT( "comment3" ), tb2.GetComment3())); xdesign->AddChild( node( wxT( "comment3" ), tb.GetComment3() ) );
xdesign->AddChild( node( wxT( "comment4" ), tb2.GetComment4())); xdesign->AddChild( node( wxT( "comment4" ), tb.GetComment4() ) );
} }
/* @todo might do a list of schematic pages /* @todo might do a list of schematic pages
......
...@@ -4,8 +4,11 @@ ...@@ -4,8 +4,11 @@
Functionality: Functionality:
Generation of csv table with table head of all existing field names Generation of csv table with table head of all existing field names
and correct assigned cell entries. and correct assigned cell entries
How to use this is explained in eeschema.pdf chapter 14. You enter a command line into the
netlist exporter using a new (custom) tab in the netlist export dialog. The command is
similar to
on Windows: on Windows:
xsltproc -o "%O.csv" "C:\Program Files (x86)\KiCad\bin\plugins\bom2csv.xsl" "%I" xsltproc -o "%O.csv" "C:\Program Files (x86)\KiCad\bin\plugins\bom2csv.xsl" "%I"
on Linux: on Linux:
...@@ -18,22 +21,10 @@ ...@@ -18,22 +21,10 @@
<!-- <!--
@package @package
Generate a command seperated file (.csv). One component per line Generate a Tab delimited list (csv file type).
One component per line
Ouput Example: Fields are
Kicad Rev: working director and file source Ref,Value, Footprint, Datasheet, Field5, Field4, price
Generated Date: date this file was generated
Document Title: the project tile
Company: the project company
Revision: the project revision
Issue Date: project issue date
Comment: This is comment 1
Comment: This is comment 2
Comment: This is comment 3
Comment: This is comment 4
Reference, Value, Fields[n], Library, Library Ref
U1, PIC32MX, Fields[n], KicadLib, PIC
--> -->
<!DOCTYPE xsl:stylesheet [ <!DOCTYPE xsl:stylesheet [
...@@ -49,49 +40,13 @@ ...@@ -49,49 +40,13 @@
<!-- main part --> <!-- main part -->
<xsl:template match="/export"> <xsl:template match="/export">
<xsl:text>Reference, Value, Footprint, Datasheet</xsl:text>
<xsl:text>Source: </xsl:text><xsl:value-of select="design/source"/><xsl:text>&nl;</xsl:text> <!-- find all existing table head entries and list each one once -->
<xsl:text>Kicad Rev: </xsl:text><xsl:value-of select="design/tool"/><xsl:text>&nl;</xsl:text>
<xsl:text>Generated Date: </xsl:text><xsl:value-of select="design/generatedDate"/><xsl:text>&nl;</xsl:text>
<xsl:text>&nl;</xsl:text>
<xsl:text>Document Title: </xsl:text><xsl:value-of select="design/title"/><xsl:text>&nl;</xsl:text>
<xsl:text>Company: </xsl:text><xsl:value-of select="design/company"/><xsl:text>&nl;</xsl:text>
<xsl:text>Revision: </xsl:text><xsl:value-of select="design/revision"/><xsl:text>&nl;</xsl:text>
<xsl:text>Issue Date: </xsl:text><xsl:value-of select="design/issueDate"/><xsl:text>&nl;</xsl:text>
<xsl:choose>
<xsl:when test="design/comment1 !=''">
<xsl:text>Comment: </xsl:text><xsl:value-of select="design/comment1"/><xsl:text>&nl;</xsl:text>
</xsl:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="design/comment2 !=''">
<xsl:text>Comment: </xsl:text><xsl:value-of select="design/comment2"/><xsl:text>&nl;</xsl:text>
</xsl:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="design/comment3 !=''">
<xsl:text>Comment: </xsl:text><xsl:value-of select="design/comment3"/><xsl:text>&nl;</xsl:text>
</xsl:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="design/comment4 !=''">
<xsl:text>Comment: </xsl:text><xsl:value-of select="design/comment4"/><xsl:text>&nl;</xsl:text>
</xsl:when>
</xsl:choose>
<xsl:text>&nl;</xsl:text>
<!-- Output table header -->
<xsl:text>Reference, Value, </xsl:text>
<xsl:for-each select="components/comp/fields/field[generate-id(.) = generate-id(key('headentr',@name)[1])]"> <xsl:for-each select="components/comp/fields/field[generate-id(.) = generate-id(key('headentr',@name)[1])]">
<xsl:value-of select="@name"/>
<xsl:text>, </xsl:text> <xsl:text>, </xsl:text>
<xsl:value-of select="@name"/>
</xsl:for-each> </xsl:for-each>
<xsl:text>Library, Library Ref</xsl:text>
<xsl:text>&nl;</xsl:text> <xsl:text>&nl;</xsl:text>
<!-- all table entries --> <!-- all table entries -->
...@@ -102,17 +57,12 @@ ...@@ -102,17 +57,12 @@
<xsl:template match="components/comp"> <xsl:template match="components/comp">
<xsl:value-of select="@ref"/><xsl:text>,</xsl:text> <xsl:value-of select="@ref"/><xsl:text>,</xsl:text>
<xsl:value-of select="value"/><xsl:text>,</xsl:text> <xsl:value-of select="value"/><xsl:text>,</xsl:text>
<xsl:value-of select="footprint"/><xsl:text>,</xsl:text>
<xsl:value-of select="datasheet"/>
<xsl:apply-templates select="fields"/> <xsl:apply-templates select="fields"/>
<xsl:apply-templates select="libsource"/>
<xsl:text>&nl;</xsl:text> <xsl:text>&nl;</xsl:text>
</xsl:template> </xsl:template>
<!-- the library selection -->
<xsl:template match="libsource">
<xsl:value-of select="@lib"/><xsl:text>,</xsl:text>
<xsl:value-of select="@part"/>
</xsl:template>
<!-- table entries with dynamic table head --> <!-- table entries with dynamic table head -->
<xsl:template match="fields"> <xsl:template match="fields">
...@@ -122,6 +72,7 @@ ...@@ -122,6 +72,7 @@
<!-- for all existing head entries --> <!-- for all existing head entries -->
<xsl:for-each select="/export/components/comp/fields/field[generate-id(.) = generate-id(key('headentr',@name)[1])]"> <xsl:for-each select="/export/components/comp/fields/field[generate-id(.) = generate-id(key('headentr',@name)[1])]">
<xsl:variable name="allnames" select="@name"/> <xsl:variable name="allnames" select="@name"/>
<xsl:text>,</xsl:text>
<!-- for all field entries in the remembered fields section --> <!-- for all field entries in the remembered fields section -->
<xsl:for-each select="$fieldvar"> <xsl:for-each select="$fieldvar">
...@@ -136,7 +87,6 @@ ...@@ -136,7 +87,6 @@
Every non-blank entry is assigned to its proper column. Every non-blank entry is assigned to its proper column.
--> -->
</xsl:for-each> </xsl:for-each>
<xsl:text>,</xsl:text>
</xsl:for-each> </xsl:for-each>
</xsl:template> </xsl:template>
......
<!--
@package
EESCHEMA BOM plugin. Creates BOM CSV files from the project net file.
Based on Stefan Helmert bom2csv.xsl
Arthur: Ronald Sousa HashDefineElectronics.com
Usage:
on Windows:
xsltproc -o "%O.csv" "C:\Program Files (x86)\KiCad\bin\plugins\bom2csv.xsl" "%I"
on Linux:
xsltproc -o "%O.csv" /usr/local/lib/kicad/plugins/bom2csv.xsl "%I"
Ouput Example:
Kicad Rev: working director and file source
Generated Date: date this file was generated
Document Title: the project tile
Company: the project company
Revision: the project revision
Issue Date: project issue date
Comment: This is comment 1
Comment: This is comment 2
Comment: This is comment 3
Comment: This is comment 4
Reference, Value, Fields[n], Library, Library Ref
U1, PIC32MX, Fields[n], KicadLib, PIC
-->
<!DOCTYPE xsl:stylesheet [
<!ENTITY nl "&#xd;&#xa;"> <!--new line CR, LF, or LF, your choice -->
]>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text"/>
<!-- for table head and empty table fields-->
<xsl:key name="headentr" match="field" use="@name"/>
<!-- main part -->
<xsl:template match="/export">
<xsl:text>Source: </xsl:text><xsl:value-of select="design/source"/><xsl:text>&nl;</xsl:text>
<xsl:text>Kicad Rev: </xsl:text><xsl:value-of select="design/tool"/><xsl:text>&nl;</xsl:text>
<xsl:text>Generated Date: </xsl:text><xsl:value-of select="design/generatedDate"/><xsl:text>&nl;</xsl:text>
<xsl:text>&nl;</xsl:text>
<xsl:text>Document Title: </xsl:text><xsl:value-of select="design/title"/><xsl:text>&nl;</xsl:text>
<xsl:text>Company: </xsl:text><xsl:value-of select="design/company"/><xsl:text>&nl;</xsl:text>
<xsl:text>Revision: </xsl:text><xsl:value-of select="design/revision"/><xsl:text>&nl;</xsl:text>
<xsl:text>Issue Date: </xsl:text><xsl:value-of select="design/issueDate"/><xsl:text>&nl;</xsl:text>
<xsl:choose>
<xsl:when test="design/comment1 !=''">
<xsl:text>Comment: </xsl:text><xsl:value-of select="design/comment1"/><xsl:text>&nl;</xsl:text>
</xsl:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="design/comment2 !=''">
<xsl:text>Comment: </xsl:text><xsl:value-of select="design/comment2"/><xsl:text>&nl;</xsl:text>
</xsl:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="design/comment3 !=''">
<xsl:text>Comment: </xsl:text><xsl:value-of select="design/comment3"/><xsl:text>&nl;</xsl:text>
</xsl:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="design/comment4 !=''">
<xsl:text>Comment: </xsl:text><xsl:value-of select="design/comment4"/><xsl:text>&nl;</xsl:text>
</xsl:when>
</xsl:choose>
<xsl:text>&nl;</xsl:text>
<!-- Output table header -->
<xsl:text>Reference, Value, </xsl:text>
<xsl:for-each select="components/comp/fields/field[generate-id(.) = generate-id(key('headentr',@name)[1])]">
<xsl:value-of select="@name"/>
<xsl:text>, </xsl:text>
</xsl:for-each>
<xsl:text>Library, Library Ref</xsl:text>
<xsl:text>&nl;</xsl:text>
<!-- all table entries -->
<xsl:apply-templates select="components/comp"/>
</xsl:template>
<!-- the table entries -->
<xsl:template match="components/comp">
<xsl:value-of select="@ref"/><xsl:text>,</xsl:text>
<xsl:value-of select="value"/><xsl:text>,</xsl:text>
<xsl:apply-templates select="fields"/>
<xsl:apply-templates select="libsource"/>
<xsl:text>&nl;</xsl:text>
</xsl:template>
<!-- the library selection -->
<xsl:template match="libsource">
<xsl:value-of select="@lib"/><xsl:text>,</xsl:text>
<xsl:value-of select="@part"/>
</xsl:template>
<!-- table entries with dynamic table head -->
<xsl:template match="fields">
<!-- remember current fields section -->
<xsl:variable name="fieldvar" select="field"/>
<!-- for all existing head entries -->
<xsl:for-each select="/export/components/comp/fields/field[generate-id(.) = generate-id(key('headentr',@name)[1])]">
<xsl:variable name="allnames" select="@name"/>
<!-- for all field entries in the remembered fields section -->
<xsl:for-each select="$fieldvar">
<!-- only if this field entry exists in this fields section -->
<xsl:if test="@name=$allnames">
<!-- content of the field -->
<xsl:value-of select="."/>
</xsl:if>
<!--
If it does not exist, use an empty cell in output for this row.
Every non-blank entry is assigned to its proper column.
-->
</xsl:for-each>
<xsl:text>,</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment