KiCad PCB EDA Suite
export_footprint_associations.cpp File Reference
#include <confirm.h>
#include <string_utils.h>
#include <macros.h>
#include <pcb_edit_frame.h>
#include <board.h>
#include <footprint.h>
#include <project.h>
#include <wildcards_and_files_ext.h>
#include <wx/filedlg.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 36 of file export_footprint_associations.cpp.

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

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

Referenced by PCB_EDIT_FRAME::RecreateCmpFileFromBoard().