Minor fixes: coding style in 3d-viewer and minor code cleanup, and some fixes in bom python scripts, which did not work when a non ascii char (but a valid utf8 symbol) was found in xml netlist. Add comments.
This commit is contained in:
parent
435ca8a7dd
commit
02c8d4db8a
|
@ -1,9 +1,9 @@
|
||||||
/*
|
/*
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012 Jean-Pierre Charras, jp.charras@wanadoo.fr
|
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras@wanadoo.fr
|
||||||
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
||||||
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -43,18 +43,12 @@ S3D_MODEL_PARSER* S3D_MODEL_PARSER::Create( S3D_MASTER* aMaster,
|
||||||
const wxString aExtension )
|
const wxString aExtension )
|
||||||
{
|
{
|
||||||
if ( aExtension == wxT( "x3d" ) )
|
if ( aExtension == wxT( "x3d" ) )
|
||||||
{
|
|
||||||
return new X3D_MODEL_PARSER( aMaster );
|
return new X3D_MODEL_PARSER( aMaster );
|
||||||
}
|
|
||||||
else if ( aExtension == wxT( "wrl" ) )
|
else if ( aExtension == wxT( "wrl" ) )
|
||||||
{
|
|
||||||
return new VRML_MODEL_PARSER( aMaster );
|
return new VRML_MODEL_PARSER( aMaster );
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const wxString S3D_MASTER::GetShape3DFullFilename()
|
const wxString S3D_MASTER::GetShape3DFullFilename()
|
||||||
{
|
{
|
||||||
|
|
|
@ -246,12 +246,27 @@ private:
|
||||||
class VRML_MODEL_PARSER: public S3D_MODEL_PARSER
|
class VRML_MODEL_PARSER: public S3D_MODEL_PARSER
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* ctor: initialize a VRML file parser
|
||||||
|
* @param aMaster = a ref to a 3D footprint shape description to fill
|
||||||
|
* by the vrml file data
|
||||||
|
*/
|
||||||
VRML_MODEL_PARSER( S3D_MASTER* aMaster );
|
VRML_MODEL_PARSER( S3D_MASTER* aMaster );
|
||||||
|
|
||||||
~VRML_MODEL_PARSER();
|
~VRML_MODEL_PARSER();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function load
|
||||||
|
* Load a 3D file and build a S3D_MASTER shape.
|
||||||
|
* file has .vrml ext and can be VRML 1 or VRML 2 format
|
||||||
|
* @param aFilename = the full filename to read
|
||||||
|
* @param aVrmlunits_to_3Dunits = the csaling factor to convert the 3D file unit
|
||||||
|
* to our internal units.
|
||||||
|
*/
|
||||||
void Load( const wxString& aFilename, double aVrmlunits_to_3Dunits );
|
void Load( const wxString& aFilename, double aVrmlunits_to_3Dunits );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
S3D_MASTER* m_curr3DShape; ///< the current 3D shape to build from the file
|
||||||
VRML1_MODEL_PARSER* vrml1_parser;
|
VRML1_MODEL_PARSER* vrml1_parser;
|
||||||
VRML2_MODEL_PARSER* vrml2_parser;
|
VRML2_MODEL_PARSER* vrml2_parser;
|
||||||
};
|
};
|
||||||
|
|
|
@ -36,6 +36,8 @@
|
||||||
#include "modelparsers.h"
|
#include "modelparsers.h"
|
||||||
#include "vrml_aux.h"
|
#include "vrml_aux.h"
|
||||||
|
|
||||||
|
#define BUFLINE_SIZE 512
|
||||||
|
|
||||||
VRML1_MODEL_PARSER::VRML1_MODEL_PARSER( S3D_MASTER* aMaster ) :
|
VRML1_MODEL_PARSER::VRML1_MODEL_PARSER( S3D_MASTER* aMaster ) :
|
||||||
S3D_MODEL_PARSER( aMaster )
|
S3D_MODEL_PARSER( aMaster )
|
||||||
{
|
{
|
||||||
|
@ -50,23 +52,19 @@ VRML1_MODEL_PARSER::VRML1_MODEL_PARSER( S3D_MASTER* aMaster ) :
|
||||||
VRML1_MODEL_PARSER::~VRML1_MODEL_PARSER()
|
VRML1_MODEL_PARSER::~VRML1_MODEL_PARSER()
|
||||||
{
|
{
|
||||||
for( unsigned int idx = 0; idx < childs.size(); idx++ )
|
for( unsigned int idx = 0; idx < childs.size(); idx++ )
|
||||||
{
|
|
||||||
delete childs[idx];
|
delete childs[idx];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void VRML1_MODEL_PARSER::Load( const wxString& aFilename, double aVrmlunits_to_3Dunits )
|
void VRML1_MODEL_PARSER::Load( const wxString& aFilename, double aVrmlunits_to_3Dunits )
|
||||||
{
|
{
|
||||||
char text[128];
|
char text[BUFLINE_SIZE];
|
||||||
|
|
||||||
// DBG( printf( "Load %s\n", GetChars(aFilename) ) );
|
// DBG( printf( "Load %s\n", GetChars(aFilename) ) );
|
||||||
m_file = wxFopen( aFilename, wxT( "rt" ) );
|
m_file = wxFopen( aFilename, wxT( "rt" ) );
|
||||||
|
|
||||||
if( m_file == NULL )
|
if( m_file == NULL )
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
float vrmlunits_to_3Dunits = aVrmlunits_to_3Dunits;
|
float vrmlunits_to_3Dunits = aVrmlunits_to_3Dunits;
|
||||||
glScalef( vrmlunits_to_3Dunits, vrmlunits_to_3Dunits, vrmlunits_to_3Dunits );
|
glScalef( vrmlunits_to_3Dunits, vrmlunits_to_3Dunits, vrmlunits_to_3Dunits );
|
||||||
|
@ -122,7 +120,7 @@ void VRML1_MODEL_PARSER::Load( const wxString& aFilename, double aVrmlunits_to_3
|
||||||
|
|
||||||
int VRML1_MODEL_PARSER::read_separator()
|
int VRML1_MODEL_PARSER::read_separator()
|
||||||
{
|
{
|
||||||
char text[128];
|
char text[BUFLINE_SIZE];
|
||||||
|
|
||||||
// DBG( printf( "Separator\n" ) );
|
// DBG( printf( "Separator\n" ) );
|
||||||
|
|
||||||
|
@ -161,10 +159,8 @@ int VRML1_MODEL_PARSER::read_separator()
|
||||||
read_NotImplemented( m_file, '}' );
|
read_NotImplemented( m_file, '}' );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -172,7 +168,7 @@ int VRML1_MODEL_PARSER::read_separator()
|
||||||
|
|
||||||
int VRML1_MODEL_PARSER::readMaterial()
|
int VRML1_MODEL_PARSER::readMaterial()
|
||||||
{
|
{
|
||||||
char text[128];
|
char text[BUFLINE_SIZE];
|
||||||
S3D_MATERIAL* material = NULL;
|
S3D_MATERIAL* material = NULL;
|
||||||
|
|
||||||
// DBG( printf( " readMaterial\n" ) );
|
// DBG( printf( " readMaterial\n" ) );
|
||||||
|
@ -229,7 +225,7 @@ int VRML1_MODEL_PARSER::readMaterial()
|
||||||
|
|
||||||
int VRML1_MODEL_PARSER::readCoordinate3()
|
int VRML1_MODEL_PARSER::readCoordinate3()
|
||||||
{
|
{
|
||||||
char text[128];
|
char text[BUFLINE_SIZE];
|
||||||
|
|
||||||
// DBG( printf( " readCoordinate3\n" ) );
|
// DBG( printf( " readCoordinate3\n" ) );
|
||||||
|
|
||||||
|
@ -257,7 +253,7 @@ int VRML1_MODEL_PARSER::readCoordinate3()
|
||||||
|
|
||||||
int VRML1_MODEL_PARSER::readIndexedFaceSet()
|
int VRML1_MODEL_PARSER::readIndexedFaceSet()
|
||||||
{
|
{
|
||||||
char text[128];
|
char text[BUFLINE_SIZE];
|
||||||
|
|
||||||
// DBG( printf( " readIndexedFaceSet\n" ) );
|
// DBG( printf( " readIndexedFaceSet\n" ) );
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include "modelparsers.h"
|
#include "modelparsers.h"
|
||||||
#include "vrml_aux.h"
|
#include "vrml_aux.h"
|
||||||
|
|
||||||
|
#define BUFLINE_SIZE 512
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Trace mask used to enable or disable the trace output of the VRML V2 parser code.
|
* Trace mask used to enable or disable the trace output of the VRML V2 parser code.
|
||||||
|
@ -71,7 +72,7 @@ VRML2_MODEL_PARSER::~VRML2_MODEL_PARSER()
|
||||||
|
|
||||||
void VRML2_MODEL_PARSER::Load( const wxString& aFilename, double aVrmlunits_to_3Dunits )
|
void VRML2_MODEL_PARSER::Load( const wxString& aFilename, double aVrmlunits_to_3Dunits )
|
||||||
{
|
{
|
||||||
char text[128];
|
char text[BUFLINE_SIZE];
|
||||||
|
|
||||||
wxLogTrace( traceVrmlV2Parser, wxT( "Load %s" ), GetChars( aFilename ) );
|
wxLogTrace( traceVrmlV2Parser, wxT( "Load %s" ), GetChars( aFilename ) );
|
||||||
m_file = wxFopen( aFilename, wxT( "rt" ) );
|
m_file = wxFopen( aFilename, wxT( "rt" ) );
|
||||||
|
@ -140,7 +141,7 @@ void VRML2_MODEL_PARSER::Load( const wxString& aFilename, double aVrmlunits_to_3
|
||||||
|
|
||||||
int VRML2_MODEL_PARSER::read_Transform()
|
int VRML2_MODEL_PARSER::read_Transform()
|
||||||
{
|
{
|
||||||
char text[128];
|
char text[BUFLINE_SIZE];
|
||||||
|
|
||||||
while( GetNextTag( m_file, text, sizeof(text) ) )
|
while( GetNextTag( m_file, text, sizeof(text) ) )
|
||||||
{
|
{
|
||||||
|
@ -255,7 +256,7 @@ int VRML2_MODEL_PARSER::read_Transform()
|
||||||
|
|
||||||
int VRML2_MODEL_PARSER::read_DEF_Coordinate()
|
int VRML2_MODEL_PARSER::read_DEF_Coordinate()
|
||||||
{
|
{
|
||||||
char text[128];
|
char text[BUFLINE_SIZE];
|
||||||
|
|
||||||
// Get the name of the definition.
|
// Get the name of the definition.
|
||||||
if( !GetNextTag( m_file, text, sizeof(text) ) )
|
if( !GetNextTag( m_file, text, sizeof(text) ) )
|
||||||
|
@ -288,7 +289,7 @@ int VRML2_MODEL_PARSER::read_DEF_Coordinate()
|
||||||
|
|
||||||
int VRML2_MODEL_PARSER::read_DEF()
|
int VRML2_MODEL_PARSER::read_DEF()
|
||||||
{
|
{
|
||||||
char text[128];
|
char text[BUFLINE_SIZE];
|
||||||
|
|
||||||
if( !GetNextTag( m_file, text, sizeof(text) ) )
|
if( !GetNextTag( m_file, text, sizeof(text) ) )
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -345,7 +346,7 @@ int VRML2_MODEL_PARSER::read_DEF()
|
||||||
|
|
||||||
int VRML2_MODEL_PARSER::read_USE()
|
int VRML2_MODEL_PARSER::read_USE()
|
||||||
{
|
{
|
||||||
char text[128];
|
char text[BUFLINE_SIZE];
|
||||||
|
|
||||||
// Get the name of the definition.
|
// Get the name of the definition.
|
||||||
if( !GetNextTag( m_file, text, sizeof(text) ) )
|
if( !GetNextTag( m_file, text, sizeof(text) ) )
|
||||||
|
@ -372,7 +373,7 @@ int VRML2_MODEL_PARSER::read_USE()
|
||||||
|
|
||||||
int VRML2_MODEL_PARSER::read_Shape()
|
int VRML2_MODEL_PARSER::read_Shape()
|
||||||
{
|
{
|
||||||
char text[128];
|
char text[BUFLINE_SIZE];
|
||||||
|
|
||||||
while( GetNextTag( m_file, text, sizeof(text) ) )
|
while( GetNextTag( m_file, text, sizeof(text) ) )
|
||||||
{
|
{
|
||||||
|
@ -422,7 +423,7 @@ int VRML2_MODEL_PARSER::read_Shape()
|
||||||
|
|
||||||
int VRML2_MODEL_PARSER::read_Appearance()
|
int VRML2_MODEL_PARSER::read_Appearance()
|
||||||
{
|
{
|
||||||
char text[128];
|
char text[BUFLINE_SIZE];
|
||||||
|
|
||||||
while( GetNextTag( m_file, text, sizeof(text) ) )
|
while( GetNextTag( m_file, text, sizeof(text) ) )
|
||||||
{
|
{
|
||||||
|
@ -450,7 +451,7 @@ int VRML2_MODEL_PARSER::read_Appearance()
|
||||||
int VRML2_MODEL_PARSER::read_material()
|
int VRML2_MODEL_PARSER::read_material()
|
||||||
{
|
{
|
||||||
S3D_MATERIAL* material = NULL;
|
S3D_MATERIAL* material = NULL;
|
||||||
char text[128];
|
char text[BUFLINE_SIZE];
|
||||||
|
|
||||||
if( GetNextTag( m_file, text, sizeof(text) ) )
|
if( GetNextTag( m_file, text, sizeof(text) ) )
|
||||||
{
|
{
|
||||||
|
@ -514,7 +515,7 @@ int VRML2_MODEL_PARSER::read_material()
|
||||||
|
|
||||||
int VRML2_MODEL_PARSER::read_Material()
|
int VRML2_MODEL_PARSER::read_Material()
|
||||||
{
|
{
|
||||||
char text[128];
|
char text[BUFLINE_SIZE];
|
||||||
glm::vec3 vertex;
|
glm::vec3 vertex;
|
||||||
|
|
||||||
while( GetNextTag( m_file, text, sizeof(text) ) )
|
while( GetNextTag( m_file, text, sizeof(text) ) )
|
||||||
|
@ -594,7 +595,7 @@ int VRML2_MODEL_PARSER::read_Material()
|
||||||
|
|
||||||
int VRML2_MODEL_PARSER::read_IndexedFaceSet()
|
int VRML2_MODEL_PARSER::read_IndexedFaceSet()
|
||||||
{
|
{
|
||||||
char text[128];
|
char text[BUFLINE_SIZE];
|
||||||
|
|
||||||
m_normalPerVertex = false;
|
m_normalPerVertex = false;
|
||||||
colorPerVertex = false;
|
colorPerVertex = false;
|
||||||
|
@ -671,7 +672,7 @@ int VRML2_MODEL_PARSER::read_IndexedFaceSet()
|
||||||
|
|
||||||
int VRML2_MODEL_PARSER::read_IndexedLineSet()
|
int VRML2_MODEL_PARSER::read_IndexedLineSet()
|
||||||
{
|
{
|
||||||
char text[128];
|
char text[BUFLINE_SIZE];
|
||||||
|
|
||||||
while( GetNextTag( m_file, text, sizeof(text) ) )
|
while( GetNextTag( m_file, text, sizeof(text) ) )
|
||||||
{
|
{
|
||||||
|
@ -787,7 +788,7 @@ int VRML2_MODEL_PARSER::read_coordIndex()
|
||||||
|
|
||||||
int VRML2_MODEL_PARSER::read_Color()
|
int VRML2_MODEL_PARSER::read_Color()
|
||||||
{
|
{
|
||||||
char text[128];
|
char text[BUFLINE_SIZE];
|
||||||
|
|
||||||
while( GetNextTag( m_file, text, sizeof(text) ) )
|
while( GetNextTag( m_file, text, sizeof(text) ) )
|
||||||
{
|
{
|
||||||
|
@ -814,7 +815,7 @@ int VRML2_MODEL_PARSER::read_Color()
|
||||||
|
|
||||||
int VRML2_MODEL_PARSER::read_Normal()
|
int VRML2_MODEL_PARSER::read_Normal()
|
||||||
{
|
{
|
||||||
char text[128];
|
char text[BUFLINE_SIZE];
|
||||||
|
|
||||||
while( GetNextTag( m_file, text, sizeof(text) ) )
|
while( GetNextTag( m_file, text, sizeof(text) ) )
|
||||||
{
|
{
|
||||||
|
@ -847,7 +848,7 @@ int VRML2_MODEL_PARSER::read_Normal()
|
||||||
|
|
||||||
int VRML2_MODEL_PARSER::read_Coordinate()
|
int VRML2_MODEL_PARSER::read_Coordinate()
|
||||||
{
|
{
|
||||||
char text[128];
|
char text[BUFLINE_SIZE];
|
||||||
|
|
||||||
while( GetNextTag( m_file, text, sizeof(text) ) )
|
while( GetNextTag( m_file, text, sizeof(text) ) )
|
||||||
{
|
{
|
||||||
|
@ -876,7 +877,7 @@ int VRML2_MODEL_PARSER::read_Coordinate()
|
||||||
*/
|
*/
|
||||||
int VRML2_MODEL_PARSER::read_CoordinateDef()
|
int VRML2_MODEL_PARSER::read_CoordinateDef()
|
||||||
{
|
{
|
||||||
char text[128];
|
char text[BUFLINE_SIZE];
|
||||||
|
|
||||||
while( GetNextTag( m_file, text, sizeof(text) ) )
|
while( GetNextTag( m_file, text, sizeof(text) ) )
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,21 +41,14 @@
|
||||||
VRML_MODEL_PARSER::VRML_MODEL_PARSER( S3D_MASTER* aMaster ) :
|
VRML_MODEL_PARSER::VRML_MODEL_PARSER( S3D_MASTER* aMaster ) :
|
||||||
S3D_MODEL_PARSER( aMaster )
|
S3D_MODEL_PARSER( aMaster )
|
||||||
{
|
{
|
||||||
vrml1_parser = new VRML1_MODEL_PARSER( aMaster );
|
m_curr3DShape = aMaster;
|
||||||
vrml2_parser = new VRML2_MODEL_PARSER( aMaster );
|
vrml1_parser = NULL;
|
||||||
|
vrml2_parser = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VRML_MODEL_PARSER::~VRML_MODEL_PARSER()
|
VRML_MODEL_PARSER::~VRML_MODEL_PARSER()
|
||||||
{
|
{
|
||||||
if( vrml1_parser )
|
|
||||||
{
|
|
||||||
delete vrml1_parser;
|
|
||||||
}
|
|
||||||
if( vrml2_parser )
|
|
||||||
{
|
|
||||||
delete vrml2_parser;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,32 +62,32 @@ void VRML_MODEL_PARSER::Load( const wxString& aFilename, double aVrmlunits_to_3D
|
||||||
file = wxFopen( aFilename, wxT( "rt" ) );
|
file = wxFopen( aFilename, wxT( "rt" ) );
|
||||||
|
|
||||||
if( file == NULL )
|
if( file == NULL )
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if( fgets( line, 11, file ) == NULL )
|
if( fgets( line, 11, file ) == NULL )
|
||||||
{
|
{
|
||||||
fclose( file );
|
fclose( file );
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose( file );
|
fclose( file );
|
||||||
|
|
||||||
|
|
||||||
if( stricmp( line, "#VRML V2.0" ) == 0 )
|
if( stricmp( line, "#VRML V2.0" ) == 0 )
|
||||||
{
|
{
|
||||||
//DBG( printf( "About to parser a #VRML V2.0 file\n" ) );
|
//DBG( printf( "About to parser a #VRML V2.0 file\n" ) );
|
||||||
|
vrml2_parser = new VRML2_MODEL_PARSER( m_curr3DShape );
|
||||||
vrml2_parser->Load( aFilename, aVrmlunits_to_3Dunits );
|
vrml2_parser->Load( aFilename, aVrmlunits_to_3Dunits );
|
||||||
|
delete vrml2_parser;
|
||||||
|
vrml2_parser = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if( stricmp( line, "#VRML V1.0" ) == 0 )
|
else if( stricmp( line, "#VRML V1.0" ) == 0 )
|
||||||
{
|
{
|
||||||
//DBG( printf( "About to parser a #VRML V1.0 file\n" ) );
|
//DBG( printf( "About to parser a #VRML V1.0 file\n" ) );
|
||||||
|
vrml1_parser = new VRML1_MODEL_PARSER( m_curr3DShape );
|
||||||
vrml1_parser->Load( aFilename, aVrmlunits_to_3Dunits );
|
vrml1_parser->Load( aFilename, aVrmlunits_to_3Dunits );
|
||||||
|
delete vrml1_parser;
|
||||||
|
vrml1_parser = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||||
<wxFormBuilder_Project>
|
<wxFormBuilder_Project>
|
||||||
<FileVersion major="1" minor="11" />
|
<FileVersion major="1" minor="13" />
|
||||||
<object class="Project" expanded="1">
|
<object class="Project" expanded="1">
|
||||||
<property name="class_decoration"></property>
|
<property name="class_decoration" />
|
||||||
<property name="code_generation">C++</property>
|
<property name="code_generation">C++</property>
|
||||||
<property name="disconnect_events">1</property>
|
<property name="disconnect_events">1</property>
|
||||||
<property name="disconnect_mode">source_name</property>
|
<property name="disconnect_mode">source_name</property>
|
||||||
|
@ -16,9 +16,9 @@
|
||||||
<property name="help_provider">none</property>
|
<property name="help_provider">none</property>
|
||||||
<property name="internationalize">1</property>
|
<property name="internationalize">1</property>
|
||||||
<property name="name">dialog_display_info_HTML</property>
|
<property name="name">dialog_display_info_HTML</property>
|
||||||
<property name="namespace"></property>
|
<property name="namespace" />
|
||||||
<property name="path">.</property>
|
<property name="path">.</property>
|
||||||
<property name="precompiled_header"></property>
|
<property name="precompiled_header" />
|
||||||
<property name="relative_path">1</property>
|
<property name="relative_path">1</property>
|
||||||
<property name="skip_lua_events">1</property>
|
<property name="skip_lua_events">1</property>
|
||||||
<property name="skip_php_events">1</property>
|
<property name="skip_php_events">1</property>
|
||||||
|
@ -29,65 +29,65 @@
|
||||||
<object class="Dialog" expanded="1">
|
<object class="Dialog" expanded="1">
|
||||||
<property name="aui_managed">0</property>
|
<property name="aui_managed">0</property>
|
||||||
<property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
|
<property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
|
||||||
<property name="bg"></property>
|
<property name="bg" />
|
||||||
<property name="center"></property>
|
<property name="center" />
|
||||||
<property name="context_help"></property>
|
<property name="context_help" />
|
||||||
<property name="context_menu">1</property>
|
<property name="context_menu">1</property>
|
||||||
<property name="enabled">1</property>
|
<property name="enabled">1</property>
|
||||||
<property name="event_handler">impl_virtual</property>
|
<property name="event_handler">impl_virtual</property>
|
||||||
<property name="extra_style"></property>
|
<property name="extra_style" />
|
||||||
<property name="fg"></property>
|
<property name="fg" />
|
||||||
<property name="font"></property>
|
<property name="font" />
|
||||||
<property name="hidden">0</property>
|
<property name="hidden">0</property>
|
||||||
<property name="id">wxID_ANY</property>
|
<property name="id">wxID_ANY</property>
|
||||||
<property name="maximum_size"></property>
|
<property name="maximum_size" />
|
||||||
<property name="minimum_size">400,120</property>
|
<property name="minimum_size">400,120</property>
|
||||||
<property name="name">DIALOG_DISPLAY_HTML_TEXT_BASE</property>
|
<property name="name">DIALOG_DISPLAY_HTML_TEXT_BASE</property>
|
||||||
<property name="pos"></property>
|
<property name="pos" />
|
||||||
<property name="size">465,202</property>
|
<property name="size">465,202</property>
|
||||||
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
|
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
|
||||||
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
|
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
|
||||||
<property name="title"></property>
|
<property name="title" />
|
||||||
<property name="tooltip"></property>
|
<property name="tooltip" />
|
||||||
<property name="window_extra_style"></property>
|
<property name="window_extra_style" />
|
||||||
<property name="window_name"></property>
|
<property name="window_name" />
|
||||||
<property name="window_style"></property>
|
<property name="window_style" />
|
||||||
<event name="OnActivate"></event>
|
<event name="OnActivate" />
|
||||||
<event name="OnActivateApp"></event>
|
<event name="OnActivateApp" />
|
||||||
<event name="OnAuiFindManager"></event>
|
<event name="OnAuiFindManager" />
|
||||||
<event name="OnAuiPaneButton"></event>
|
<event name="OnAuiPaneButton" />
|
||||||
<event name="OnAuiPaneClose"></event>
|
<event name="OnAuiPaneClose" />
|
||||||
<event name="OnAuiPaneMaximize"></event>
|
<event name="OnAuiPaneMaximize" />
|
||||||
<event name="OnAuiPaneRestore"></event>
|
<event name="OnAuiPaneRestore" />
|
||||||
<event name="OnAuiRender"></event>
|
<event name="OnAuiRender" />
|
||||||
<event name="OnChar"></event>
|
<event name="OnChar" />
|
||||||
<event name="OnClose"></event>
|
<event name="OnClose" />
|
||||||
<event name="OnEnterWindow"></event>
|
<event name="OnEnterWindow" />
|
||||||
<event name="OnEraseBackground"></event>
|
<event name="OnEraseBackground" />
|
||||||
<event name="OnHibernate"></event>
|
<event name="OnHibernate" />
|
||||||
<event name="OnIconize"></event>
|
<event name="OnIconize" />
|
||||||
<event name="OnIdle"></event>
|
<event name="OnIdle" />
|
||||||
<event name="OnInitDialog"></event>
|
<event name="OnInitDialog" />
|
||||||
<event name="OnKeyDown"></event>
|
<event name="OnKeyDown" />
|
||||||
<event name="OnKeyUp"></event>
|
<event name="OnKeyUp" />
|
||||||
<event name="OnKillFocus"></event>
|
<event name="OnKillFocus" />
|
||||||
<event name="OnLeaveWindow"></event>
|
<event name="OnLeaveWindow" />
|
||||||
<event name="OnLeftDClick"></event>
|
<event name="OnLeftDClick" />
|
||||||
<event name="OnLeftDown"></event>
|
<event name="OnLeftDown" />
|
||||||
<event name="OnLeftUp"></event>
|
<event name="OnLeftUp" />
|
||||||
<event name="OnMiddleDClick"></event>
|
<event name="OnMiddleDClick" />
|
||||||
<event name="OnMiddleDown"></event>
|
<event name="OnMiddleDown" />
|
||||||
<event name="OnMiddleUp"></event>
|
<event name="OnMiddleUp" />
|
||||||
<event name="OnMotion"></event>
|
<event name="OnMotion" />
|
||||||
<event name="OnMouseEvents"></event>
|
<event name="OnMouseEvents" />
|
||||||
<event name="OnMouseWheel"></event>
|
<event name="OnMouseWheel" />
|
||||||
<event name="OnPaint"></event>
|
<event name="OnPaint" />
|
||||||
<event name="OnRightDClick"></event>
|
<event name="OnRightDClick" />
|
||||||
<event name="OnRightDown"></event>
|
<event name="OnRightDown" />
|
||||||
<event name="OnRightUp"></event>
|
<event name="OnRightUp" />
|
||||||
<event name="OnSetFocus"></event>
|
<event name="OnSetFocus" />
|
||||||
<event name="OnSize"></event>
|
<event name="OnSize" />
|
||||||
<event name="OnUpdateUI"></event>
|
<event name="OnUpdateUI" />
|
||||||
<object class="wxBoxSizer" expanded="1">
|
<object class="wxBoxSizer" expanded="1">
|
||||||
<property name="minimum_size">-1,-1</property>
|
<property name="minimum_size">-1,-1</property>
|
||||||
<property name="name">bMainSizer</property>
|
<property name="name">bMainSizer</property>
|
||||||
|
@ -102,79 +102,79 @@
|
||||||
<property name="LeftDockable">1</property>
|
<property name="LeftDockable">1</property>
|
||||||
<property name="RightDockable">1</property>
|
<property name="RightDockable">1</property>
|
||||||
<property name="TopDockable">1</property>
|
<property name="TopDockable">1</property>
|
||||||
<property name="aui_layer"></property>
|
<property name="aui_layer" />
|
||||||
<property name="aui_name"></property>
|
<property name="aui_name" />
|
||||||
<property name="aui_position"></property>
|
<property name="aui_position" />
|
||||||
<property name="aui_row"></property>
|
<property name="aui_row" />
|
||||||
<property name="best_size"></property>
|
<property name="best_size" />
|
||||||
<property name="bg"></property>
|
<property name="bg" />
|
||||||
<property name="caption"></property>
|
<property name="caption" />
|
||||||
<property name="caption_visible">1</property>
|
<property name="caption_visible">1</property>
|
||||||
<property name="center_pane">0</property>
|
<property name="center_pane">0</property>
|
||||||
<property name="close_button">1</property>
|
<property name="close_button">1</property>
|
||||||
<property name="context_help"></property>
|
<property name="context_help" />
|
||||||
<property name="context_menu">1</property>
|
<property name="context_menu">1</property>
|
||||||
<property name="default_pane">0</property>
|
<property name="default_pane">0</property>
|
||||||
<property name="dock">Dock</property>
|
<property name="dock">Dock</property>
|
||||||
<property name="dock_fixed">0</property>
|
<property name="dock_fixed">0</property>
|
||||||
<property name="docking">Left</property>
|
<property name="docking">Left</property>
|
||||||
<property name="enabled">1</property>
|
<property name="enabled">1</property>
|
||||||
<property name="fg"></property>
|
<property name="fg" />
|
||||||
<property name="floatable">1</property>
|
<property name="floatable">1</property>
|
||||||
<property name="font"></property>
|
<property name="font" />
|
||||||
<property name="gripper">0</property>
|
<property name="gripper">0</property>
|
||||||
<property name="hidden">0</property>
|
<property name="hidden">0</property>
|
||||||
<property name="id">wxID_ANY</property>
|
<property name="id">wxID_ANY</property>
|
||||||
<property name="max_size"></property>
|
<property name="max_size" />
|
||||||
<property name="maximize_button">0</property>
|
<property name="maximize_button">0</property>
|
||||||
<property name="maximum_size"></property>
|
<property name="maximum_size" />
|
||||||
<property name="min_size"></property>
|
<property name="min_size" />
|
||||||
<property name="minimize_button">0</property>
|
<property name="minimize_button">0</property>
|
||||||
<property name="minimum_size">-1,-1</property>
|
<property name="minimum_size">-1,-1</property>
|
||||||
<property name="moveable">1</property>
|
<property name="moveable">1</property>
|
||||||
<property name="name">m_htmlWindow</property>
|
<property name="name">m_htmlWindow</property>
|
||||||
<property name="pane_border">1</property>
|
<property name="pane_border">1</property>
|
||||||
<property name="pane_position"></property>
|
<property name="pane_position" />
|
||||||
<property name="pane_size"></property>
|
<property name="pane_size" />
|
||||||
<property name="permission">public</property>
|
<property name="permission">public</property>
|
||||||
<property name="pin_button">1</property>
|
<property name="pin_button">1</property>
|
||||||
<property name="pos"></property>
|
<property name="pos" />
|
||||||
<property name="resize">Resizable</property>
|
<property name="resize">Resizable</property>
|
||||||
<property name="show">1</property>
|
<property name="show">1</property>
|
||||||
<property name="size"></property>
|
<property name="size" />
|
||||||
<property name="style">wxHW_SCROLLBAR_AUTO</property>
|
<property name="style">wxHW_SCROLLBAR_AUTO</property>
|
||||||
<property name="subclass"></property>
|
<property name="subclass" />
|
||||||
<property name="toolbar_pane">0</property>
|
<property name="toolbar_pane">0</property>
|
||||||
<property name="tooltip"></property>
|
<property name="tooltip" />
|
||||||
<property name="window_extra_style"></property>
|
<property name="window_extra_style" />
|
||||||
<property name="window_name"></property>
|
<property name="window_name" />
|
||||||
<property name="window_style">wxSUNKEN_BORDER</property>
|
<property name="window_style">wxSUNKEN_BORDER</property>
|
||||||
<event name="OnChar"></event>
|
<event name="OnChar" />
|
||||||
<event name="OnEnterWindow"></event>
|
<event name="OnEnterWindow" />
|
||||||
<event name="OnEraseBackground"></event>
|
<event name="OnEraseBackground" />
|
||||||
<event name="OnHtmlCellClicked"></event>
|
<event name="OnHtmlCellClicked" />
|
||||||
<event name="OnHtmlCellHover"></event>
|
<event name="OnHtmlCellHover" />
|
||||||
<event name="OnHtmlLinkClicked">OnHTMLLinkClicked</event>
|
<event name="OnHtmlLinkClicked">OnHTMLLinkClicked</event>
|
||||||
<event name="OnKeyDown"></event>
|
<event name="OnKeyDown" />
|
||||||
<event name="OnKeyUp"></event>
|
<event name="OnKeyUp" />
|
||||||
<event name="OnKillFocus"></event>
|
<event name="OnKillFocus" />
|
||||||
<event name="OnLeaveWindow"></event>
|
<event name="OnLeaveWindow" />
|
||||||
<event name="OnLeftDClick"></event>
|
<event name="OnLeftDClick" />
|
||||||
<event name="OnLeftDown"></event>
|
<event name="OnLeftDown" />
|
||||||
<event name="OnLeftUp"></event>
|
<event name="OnLeftUp" />
|
||||||
<event name="OnMiddleDClick"></event>
|
<event name="OnMiddleDClick" />
|
||||||
<event name="OnMiddleDown"></event>
|
<event name="OnMiddleDown" />
|
||||||
<event name="OnMiddleUp"></event>
|
<event name="OnMiddleUp" />
|
||||||
<event name="OnMotion"></event>
|
<event name="OnMotion" />
|
||||||
<event name="OnMouseEvents"></event>
|
<event name="OnMouseEvents" />
|
||||||
<event name="OnMouseWheel"></event>
|
<event name="OnMouseWheel" />
|
||||||
<event name="OnPaint"></event>
|
<event name="OnPaint" />
|
||||||
<event name="OnRightDClick"></event>
|
<event name="OnRightDClick" />
|
||||||
<event name="OnRightDown"></event>
|
<event name="OnRightDown" />
|
||||||
<event name="OnRightUp"></event>
|
<event name="OnRightUp" />
|
||||||
<event name="OnSetFocus"></event>
|
<event name="OnSetFocus" />
|
||||||
<event name="OnSize"></event>
|
<event name="OnSize" />
|
||||||
<event name="OnUpdateUI"></event>
|
<event name="OnUpdateUI" />
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
<object class="sizeritem" expanded="1">
|
<object class="sizeritem" expanded="1">
|
||||||
|
@ -186,17 +186,17 @@
|
||||||
<property name="LeftDockable">1</property>
|
<property name="LeftDockable">1</property>
|
||||||
<property name="RightDockable">1</property>
|
<property name="RightDockable">1</property>
|
||||||
<property name="TopDockable">1</property>
|
<property name="TopDockable">1</property>
|
||||||
<property name="aui_layer"></property>
|
<property name="aui_layer" />
|
||||||
<property name="aui_name"></property>
|
<property name="aui_name" />
|
||||||
<property name="aui_position"></property>
|
<property name="aui_position" />
|
||||||
<property name="aui_row"></property>
|
<property name="aui_row" />
|
||||||
<property name="best_size"></property>
|
<property name="best_size" />
|
||||||
<property name="bg"></property>
|
<property name="bg" />
|
||||||
<property name="caption"></property>
|
<property name="caption" />
|
||||||
<property name="caption_visible">1</property>
|
<property name="caption_visible">1</property>
|
||||||
<property name="center_pane">0</property>
|
<property name="center_pane">0</property>
|
||||||
<property name="close_button">1</property>
|
<property name="close_button">1</property>
|
||||||
<property name="context_help"></property>
|
<property name="context_help" />
|
||||||
<property name="context_menu">1</property>
|
<property name="context_menu">1</property>
|
||||||
<property name="default">1</property>
|
<property name="default">1</property>
|
||||||
<property name="default_pane">0</property>
|
<property name="default_pane">0</property>
|
||||||
|
@ -204,65 +204,65 @@
|
||||||
<property name="dock_fixed">0</property>
|
<property name="dock_fixed">0</property>
|
||||||
<property name="docking">Left</property>
|
<property name="docking">Left</property>
|
||||||
<property name="enabled">1</property>
|
<property name="enabled">1</property>
|
||||||
<property name="fg"></property>
|
<property name="fg" />
|
||||||
<property name="floatable">1</property>
|
<property name="floatable">1</property>
|
||||||
<property name="font"></property>
|
<property name="font" />
|
||||||
<property name="gripper">0</property>
|
<property name="gripper">0</property>
|
||||||
<property name="hidden">0</property>
|
<property name="hidden">0</property>
|
||||||
<property name="id">wxID_CANCEL</property>
|
<property name="id">wxID_CANCEL</property>
|
||||||
<property name="label">Close</property>
|
<property name="label">Close</property>
|
||||||
<property name="max_size"></property>
|
<property name="max_size" />
|
||||||
<property name="maximize_button">0</property>
|
<property name="maximize_button">0</property>
|
||||||
<property name="maximum_size"></property>
|
<property name="maximum_size" />
|
||||||
<property name="min_size"></property>
|
<property name="min_size" />
|
||||||
<property name="minimize_button">0</property>
|
<property name="minimize_button">0</property>
|
||||||
<property name="minimum_size"></property>
|
<property name="minimum_size" />
|
||||||
<property name="moveable">1</property>
|
<property name="moveable">1</property>
|
||||||
<property name="name">m_buttonClose</property>
|
<property name="name">m_buttonClose</property>
|
||||||
<property name="pane_border">1</property>
|
<property name="pane_border">1</property>
|
||||||
<property name="pane_position"></property>
|
<property name="pane_position" />
|
||||||
<property name="pane_size"></property>
|
<property name="pane_size" />
|
||||||
<property name="permission">protected</property>
|
<property name="permission">protected</property>
|
||||||
<property name="pin_button">1</property>
|
<property name="pin_button">1</property>
|
||||||
<property name="pos"></property>
|
<property name="pos" />
|
||||||
<property name="resize">Resizable</property>
|
<property name="resize">Resizable</property>
|
||||||
<property name="show">1</property>
|
<property name="show">1</property>
|
||||||
<property name="size"></property>
|
<property name="size" />
|
||||||
<property name="style">wxBU_EXACTFIT</property>
|
<property name="style">wxBU_EXACTFIT</property>
|
||||||
<property name="subclass"></property>
|
<property name="subclass" />
|
||||||
<property name="toolbar_pane">0</property>
|
<property name="toolbar_pane">0</property>
|
||||||
<property name="tooltip"></property>
|
<property name="tooltip" />
|
||||||
<property name="validator_data_type"></property>
|
<property name="validator_data_type" />
|
||||||
<property name="validator_style">wxFILTER_NONE</property>
|
<property name="validator_style">wxFILTER_NONE</property>
|
||||||
<property name="validator_type">wxDefaultValidator</property>
|
<property name="validator_type">wxDefaultValidator</property>
|
||||||
<property name="validator_variable"></property>
|
<property name="validator_variable" />
|
||||||
<property name="window_extra_style"></property>
|
<property name="window_extra_style" />
|
||||||
<property name="window_name"></property>
|
<property name="window_name" />
|
||||||
<property name="window_style"></property>
|
<property name="window_style" />
|
||||||
<event name="OnButtonClick">OnCloseButtonClick</event>
|
<event name="OnButtonClick">OnCloseButtonClick</event>
|
||||||
<event name="OnChar"></event>
|
<event name="OnChar" />
|
||||||
<event name="OnEnterWindow"></event>
|
<event name="OnEnterWindow" />
|
||||||
<event name="OnEraseBackground"></event>
|
<event name="OnEraseBackground" />
|
||||||
<event name="OnKeyDown"></event>
|
<event name="OnKeyDown" />
|
||||||
<event name="OnKeyUp"></event>
|
<event name="OnKeyUp" />
|
||||||
<event name="OnKillFocus"></event>
|
<event name="OnKillFocus" />
|
||||||
<event name="OnLeaveWindow"></event>
|
<event name="OnLeaveWindow" />
|
||||||
<event name="OnLeftDClick"></event>
|
<event name="OnLeftDClick" />
|
||||||
<event name="OnLeftDown"></event>
|
<event name="OnLeftDown" />
|
||||||
<event name="OnLeftUp"></event>
|
<event name="OnLeftUp" />
|
||||||
<event name="OnMiddleDClick"></event>
|
<event name="OnMiddleDClick" />
|
||||||
<event name="OnMiddleDown"></event>
|
<event name="OnMiddleDown" />
|
||||||
<event name="OnMiddleUp"></event>
|
<event name="OnMiddleUp" />
|
||||||
<event name="OnMotion"></event>
|
<event name="OnMotion" />
|
||||||
<event name="OnMouseEvents"></event>
|
<event name="OnMouseEvents" />
|
||||||
<event name="OnMouseWheel"></event>
|
<event name="OnMouseWheel" />
|
||||||
<event name="OnPaint"></event>
|
<event name="OnPaint" />
|
||||||
<event name="OnRightDClick"></event>
|
<event name="OnRightDClick" />
|
||||||
<event name="OnRightDown"></event>
|
<event name="OnRightDown" />
|
||||||
<event name="OnRightUp"></event>
|
<event name="OnRightUp" />
|
||||||
<event name="OnSetFocus"></event>
|
<event name="OnSetFocus" />
|
||||||
<event name="OnSize"></event>
|
<event name="OnSize" />
|
||||||
<event name="OnUpdateUI"></event>
|
<event name="OnUpdateUI" />
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
|
|
|
@ -3,6 +3,13 @@
|
||||||
#
|
#
|
||||||
# Example: Sorted and Grouped CSV BOM
|
# Example: Sorted and Grouped CSV BOM
|
||||||
#
|
#
|
||||||
|
"""
|
||||||
|
@package
|
||||||
|
Generate a csv BOM list.
|
||||||
|
Components are sorted by ref and grouped by value
|
||||||
|
Fields are (if exist)
|
||||||
|
Item, Qty, Reference(s), Value, LibPart, Footprint, Datasheet
|
||||||
|
"""
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
|
@ -11,6 +18,29 @@ import kicad_netlist_reader
|
||||||
import csv
|
import csv
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
def myEqu(self, other):
|
||||||
|
"""myEqu is a more advanced equivalence function for components which is
|
||||||
|
used by component grouping. Normal operation is to group components based
|
||||||
|
on their value and footprint.
|
||||||
|
|
||||||
|
In this example of a custom equivalency operator we compare the
|
||||||
|
value, the part name and the footprint.
|
||||||
|
|
||||||
|
"""
|
||||||
|
result = True
|
||||||
|
if self.getValue() != other.getValue():
|
||||||
|
result = False
|
||||||
|
elif self.getPartName() != other.getPartName():
|
||||||
|
result = False
|
||||||
|
elif self.getFootprint() != other.getFootprint():
|
||||||
|
result = False
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
# Override the component equivalence operator - it is important to do this
|
||||||
|
# before loading the netlist, otherwise all components will have the original
|
||||||
|
# equivalency operator.
|
||||||
|
kicad_netlist_reader.comp.__eq__ = myEqu
|
||||||
|
|
||||||
if len(sys.argv) != 3:
|
if len(sys.argv) != 3:
|
||||||
print("Usage ", __file__, "<generic_netlist.xml> <output.csv>", file=sys.stderr)
|
print("Usage ", __file__, "<generic_netlist.xml> <output.csv>", file=sys.stderr)
|
||||||
|
@ -48,17 +78,18 @@ columns = ['Item', 'Qty', 'Reference(s)', 'Value', 'LibPart', 'Footprint', 'Data
|
||||||
# Create a new csv writer object to use as the output formatter
|
# Create a new csv writer object to use as the output formatter
|
||||||
out = csv.writer( f, lineterminator='\n', delimiter=',', quotechar='\"', quoting=csv.QUOTE_MINIMAL )
|
out = csv.writer( f, lineterminator='\n', delimiter=',', quotechar='\"', quoting=csv.QUOTE_MINIMAL )
|
||||||
|
|
||||||
# override csv.writer's writerow() to support utf8 encoding:
|
# override csv.writer's writerow() to support encoding conversion (initial encoding is utf8):
|
||||||
def writerow( acsvwriter, columns ):
|
def writerow( acsvwriter, columns ):
|
||||||
utf8row = []
|
utf8row = []
|
||||||
for col in columns:
|
for col in columns:
|
||||||
utf8row.append( str(col).encode('utf8') )
|
utf8row.append( str(col) ) # currently, no change
|
||||||
acsvwriter.writerow( utf8row )
|
acsvwriter.writerow( utf8row )
|
||||||
|
|
||||||
# Output a set of rows as a header providing general information
|
# Output a set of rows as a header providing general information
|
||||||
writerow( out, ['Source:', net.getSource()] )
|
writerow( out, ['Source:', net.getSource()] )
|
||||||
writerow( out, ['Date:', net.getDate()] )
|
writerow( out, ['Date:', net.getDate()] )
|
||||||
writerow( out, ['Tool:', net.getTool()] )
|
writerow( out, ['Tool:', net.getTool()] )
|
||||||
|
writerow( out, ['Generator:', sys.argv[0]] )
|
||||||
writerow( out, ['Component Count:', len(components)] )
|
writerow( out, ['Component Count:', len(components)] )
|
||||||
writerow( out, [] )
|
writerow( out, [] )
|
||||||
writerow( out, ['Individual Components:'] )
|
writerow( out, ['Individual Components:'] )
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
"""
|
"""
|
||||||
@package
|
@package
|
||||||
Generate a Tab delimited list (csv file type).
|
Generate a Tab delimited list (csv file type).
|
||||||
Components are sorted by ref and grouped by value
|
Components are sorted by ref and grouped by value with same footprint
|
||||||
Fields are (if exist)
|
Fields are (if exist)
|
||||||
'Ref', 'Qnty', 'Value', 'Sch lib name', 'footprint', 'Description', 'Vendor'
|
'Ref', 'Qnty', 'Value', 'Cmp name', 'Footprint', 'Description', 'Vendor'
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Import the KiCad python helper module and the csv formatter
|
# Import the KiCad python helper module and the csv formatter
|
||||||
|
@ -37,8 +37,9 @@ out = csv.writer(f, lineterminator='\n', delimiter=',', quotechar='\"', quoting=
|
||||||
out.writerow(['Source:', net.getSource()])
|
out.writerow(['Source:', net.getSource()])
|
||||||
out.writerow(['Date:', net.getDate()])
|
out.writerow(['Date:', net.getDate()])
|
||||||
out.writerow(['Tool:', net.getTool()])
|
out.writerow(['Tool:', net.getTool()])
|
||||||
|
out.writerow( ['Generator:', sys.argv[0]] )
|
||||||
out.writerow(['Component Count:', len(net.components)])
|
out.writerow(['Component Count:', len(net.components)])
|
||||||
out.writerow(['Ref', 'Qnty', 'Value', 'Sch lib name', 'footprint', 'Description', 'Vendor'])
|
out.writerow(['Ref', 'Qnty', 'Value', 'Cmp name', 'Footprint', 'Description', 'Vendor'])
|
||||||
|
|
||||||
# Get all of the components in groups of matching parts + values
|
# Get all of the components in groups of matching parts + values
|
||||||
# (see ky_generic_netlist_reader.py)
|
# (see ky_generic_netlist_reader.py)
|
||||||
|
@ -55,7 +56,7 @@ for group in grouped:
|
||||||
c = component
|
c = component
|
||||||
|
|
||||||
# Fill in the component groups common data
|
# Fill in the component groups common data
|
||||||
out.writerow([refs, len(group), c.getValue(), c.getLibName() + "/" + c.getPartName(), c.getFootprint(),
|
out.writerow([refs, len(group), c.getValue(), c.getPartName(), c.getFootprint(),
|
||||||
c.getDescription(), c.getField("Vendor")])
|
c.getDescription(), c.getField("Vendor")])
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
Generate a HTML BOM list.
|
Generate a HTML BOM list.
|
||||||
Components are sorted and grouped by value
|
Components are sorted and grouped by value
|
||||||
Fields are (if exist)
|
Fields are (if exist)
|
||||||
Ref, Quantity, Value, Part, Datasheet, Description, Vendor
|
Ref, Quantity, Value, Part, Footprint, Description, Vendor
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ html = """
|
||||||
def myEqu(self, other):
|
def myEqu(self, other):
|
||||||
"""myEqu is a more advanced equivalence function for components which is
|
"""myEqu is a more advanced equivalence function for components which is
|
||||||
used by component grouping. Normal operation is to group components based
|
used by component grouping. Normal operation is to group components based
|
||||||
on their Value, Library source, and Library part.
|
on their Value and Footprint.
|
||||||
|
|
||||||
In this example of a more advanced equivalency operator we also compare the
|
In this example of a more advanced equivalency operator we also compare the
|
||||||
custom fields Voltage, Tolerance and Manufacturer as well as the assigned
|
custom fields Voltage, Tolerance and Manufacturer as well as the assigned
|
||||||
|
@ -54,8 +54,6 @@ def myEqu(self, other):
|
||||||
result = True
|
result = True
|
||||||
if self.getValue() != other.getValue():
|
if self.getValue() != other.getValue():
|
||||||
result = False
|
result = False
|
||||||
elif self.getLibName() != other.getLibName():
|
|
||||||
result = False
|
|
||||||
elif self.getPartName() != other.getPartName():
|
elif self.getPartName() != other.getPartName():
|
||||||
result = False
|
result = False
|
||||||
elif self.getFootprint() != other.getFootprint():
|
elif self.getFootprint() != other.getFootprint():
|
||||||
|
@ -72,7 +70,7 @@ def myEqu(self, other):
|
||||||
# Override the component equivalence operator - it is important to do this
|
# Override the component equivalence operator - it is important to do this
|
||||||
# before loading the netlist, otherwise all components will have the original
|
# before loading the netlist, otherwise all components will have the original
|
||||||
# equivalency operator.
|
# equivalency operator.
|
||||||
kicad_netlist_reader.comp.__equ__ = myEqu
|
kicad_netlist_reader.comp.__eq__ = myEqu
|
||||||
|
|
||||||
# Generate an instance of a generic netlist, and load the netlist tree from
|
# Generate an instance of a generic netlist, and load the netlist tree from
|
||||||
# <file>.tmp. If the file doesn't exist, execution will stop
|
# <file>.tmp. If the file doesn't exist, execution will stop
|
||||||
|
@ -95,7 +93,7 @@ html = html.replace('<!--COMPCOUNT-->', "<b>Component Count:</b>" + \
|
||||||
str(len(net.components)))
|
str(len(net.components)))
|
||||||
|
|
||||||
row = "<tr><th style='width:640px'>Ref</th>" + "<th>Qnty</th>"
|
row = "<tr><th style='width:640px'>Ref</th>" + "<th>Qnty</th>"
|
||||||
row += "<th>Value</th>" + "<th>Part</th>" + "<th>Datasheet</th>"
|
row += "<th>Value</th>" + "<th>Part</th>" + "<th>Footprint</th>"
|
||||||
row += "<th>Description</th>" + "<th>Vendor</th></tr>"
|
row += "<th>Description</th>" + "<th>Vendor</th></tr>"
|
||||||
|
|
||||||
html = html.replace('<!--TABLEROW-->', row + "<!--TABLEROW-->")
|
html = html.replace('<!--TABLEROW-->', row + "<!--TABLEROW-->")
|
||||||
|
@ -121,7 +119,7 @@ for group in grouped:
|
||||||
row = "\n "
|
row = "\n "
|
||||||
row += "<tr><td>" + refs +"</td><td>" + str(len(group))
|
row += "<tr><td>" + refs +"</td><td>" + str(len(group))
|
||||||
row += "</td><td>" + c.getValue() + "</td><td>" + c.getLibName() + ":"
|
row += "</td><td>" + c.getValue() + "</td><td>" + c.getLibName() + ":"
|
||||||
row += c.getPartName() + "</td><td>" + c.getDatasheet() + "</td><td>"
|
row += c.getPartName() + "</td><td>" + c.getFootprint() + "</td><td>"
|
||||||
row += c.getDescription() + "</td><td>" + c.getField("Vendor")
|
row += c.getDescription() + "</td><td>" + c.getField("Vendor")
|
||||||
row += "</td></tr>"
|
row += "</td></tr>"
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
# KiCad python module for interpreting generic netlists which can be used
|
# KiCad python module for interpreting generic netlists which can be used
|
||||||
# to generate Bills of materials, etc.
|
# to generate Bills of materials, etc.
|
||||||
#
|
#
|
||||||
|
# Remember these files use UTF8 encoding
|
||||||
|
#
|
||||||
# No string formatting is used on purpose as the only string formatting that
|
# No string formatting is used on purpose as the only string formatting that
|
||||||
# is current compatible with python 2.4+ to 3.0+ is the '%' method, and that
|
# is current compatible with python 2.4+ to 3.0+ is the '%' method, and that
|
||||||
# is due to be deprecated in 3.0+ soon
|
# is due to be deprecated in 3.0+ soon
|
||||||
|
@ -304,11 +306,23 @@ class comp():
|
||||||
self.grouped = False
|
self.grouped = False
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
"""Equlivalency operator, remember this can be easily overloaded"""
|
""" Equivalency operator, remember this can be easily overloaded
|
||||||
|
2 components are equivalent ( i.e. can be grouped
|
||||||
|
if they have same value and same footprint
|
||||||
|
|
||||||
|
Override the component equivalence operator must be done before
|
||||||
|
loading the netlist, otherwise all components will have the original
|
||||||
|
equivalency operator.
|
||||||
|
|
||||||
|
You have to define a comparison module (for instance named myEqu)
|
||||||
|
and add the line;
|
||||||
|
kicad_netlist_reader.comp.__eq__ = myEqu
|
||||||
|
in your bom generator script before calling the netliste reader by something like:
|
||||||
|
net = kicad_netlist_reader.netlist(sys.argv[1])
|
||||||
|
"""
|
||||||
result = False
|
result = False
|
||||||
if self.getValue() == other.getValue():
|
if self.getValue() == other.getValue():
|
||||||
if self.getLibName() == other.getLibName():
|
if self.getFootprint() == other.getFootprint():
|
||||||
if self.getPartName() == other.getPartName():
|
|
||||||
result = True
|
result = True
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -331,7 +345,7 @@ class comp():
|
||||||
v.setChars(value)
|
v.setChars(value)
|
||||||
|
|
||||||
def getValue(self):
|
def getValue(self):
|
||||||
return self.element.get("value")
|
return self.element.get("value").encode( "utf-8" )
|
||||||
|
|
||||||
def getField(self, name, libraryToo=True):
|
def getField(self, name, libraryToo=True):
|
||||||
"""Return the value of a field named name. The component is first
|
"""Return the value of a field named name. The component is first
|
||||||
|
@ -347,7 +361,7 @@ class comp():
|
||||||
|
|
||||||
field = self.element.get("field", "name", name)
|
field = self.element.get("field", "name", name)
|
||||||
if field == "" and libraryToo:
|
if field == "" and libraryToo:
|
||||||
field = self.libpart.getField(name)
|
field = self.libpart.getField(name).encode( "utf-8" )
|
||||||
return field
|
return field
|
||||||
|
|
||||||
def getFieldNames(self):
|
def getFieldNames(self):
|
||||||
|
@ -360,7 +374,7 @@ class comp():
|
||||||
fields = self.element.getChild('fields')
|
fields = self.element.getChild('fields')
|
||||||
if fields:
|
if fields:
|
||||||
for f in fields.getChildren():
|
for f in fields.getChildren():
|
||||||
fieldNames.append( f.get('field','name') )
|
fieldNames.append( f.get('field','name').encode( "utf-8" ) )
|
||||||
return fieldNames
|
return fieldNames
|
||||||
|
|
||||||
def getRef(self):
|
def getRef(self):
|
||||||
|
@ -382,7 +396,7 @@ class comp():
|
||||||
return self.element.get("tstamp")
|
return self.element.get("tstamp")
|
||||||
|
|
||||||
def getDescription(self):
|
def getDescription(self):
|
||||||
return self.libpart.getDescription()
|
return self.libpart.getDescription().encode( "utf-8" )
|
||||||
|
|
||||||
|
|
||||||
class netlist():
|
class netlist():
|
||||||
|
|
Loading…
Reference in New Issue