KiCad PCB EDA Suite
export_footprint_associations.cpp File Reference
#include <confirm.h>
#include <kicad_string.h>
#include <macros.h>
#include <pcb_edit_frame.h>
#include <board.h>
#include <footprint.h>
#include <project.h>
#include <wildcards_and_files_ext.h>

Go to the source code of this file.

Functions

bool RecreateCmpFile (BOARD *aBrd, const wxString &aFullCmpFileName)
 

Function Documentation

◆ RecreateCmpFile()

bool RecreateCmpFile ( BOARD aBrd,
const wxString &  aFullCmpFileName 
)

Definition at line 34 of file export_footprint_associations.cpp.

35 {
36  FILE* cmpFile = wxFopen( aFullCmpFileName, wxT( "wt" ) );
37 
38  if( cmpFile == NULL )
39  return false;
40 
41  fprintf( cmpFile, "Cmp-Mod V01 Created by PcbNew date = %s\n", TO_UTF8( DateAndTime() ) );
42 
43  for( FOOTPRINT* fp : aBrd->Footprints() )
44  {
45  fprintf( cmpFile, "\nBeginCmp\n" );
46  fprintf( cmpFile, "TimeStamp = %s\n", TO_UTF8( fp->m_Uuid.AsString() ) );
47  fprintf( cmpFile, "Path = %s\n", TO_UTF8( fp->GetPath().AsString() ) );
48  fprintf( cmpFile, "Reference = %s;\n",
49  !fp->GetReference().IsEmpty() ? TO_UTF8( fp->GetReference() ) : "[NoRef]" );
50  fprintf( cmpFile, "ValeurCmp = %s;\n",
51  !fp->GetValue().IsEmpty() ? TO_UTF8( fp->GetValue() ) : "[NoVal]" );
52  fprintf( cmpFile, "IdModule = %s;\n", fp->GetFPID().Format().c_str() );
53  fprintf( cmpFile, "EndCmp\n" );
54  }
55 
56  fprintf( cmpFile, "\nEndListe\n" );
57  fclose( cmpFile );
58 
59  return true;
60 }
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
#define NULL
FOOTPRINTS & Footprints()
Definition: board.h:305
wxString DateAndTime()
Definition: string.cpp:431

References DateAndTime(), BOARD::Footprints(), NULL, and TO_UTF8.

Referenced by PCB_EDIT_FRAME::RecreateCmpFileFromBoard().