diff --git a/pcbnew/pcad2kicadpcb_plugin/pcad2kicad_common.cpp b/pcbnew/pcad2kicadpcb_plugin/pcad2kicad_common.cpp index fc57b6cbc7..e6403434c7 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcad2kicad_common.cpp +++ b/pcbnew/pcad2kicadpcb_plugin/pcad2kicad_common.cpp @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -225,6 +226,18 @@ wxString ValidateName( wxString aName ) } +wxString ValidateReference( wxString aRef ) +{ + wxRegEx reRef; + reRef.Compile( wxT( "^[[:digit:]][[:digit:]]*$" ) ); + + if( reRef.Matches( aRef ) ) + aRef.Prepend( wxT( '.' ) ); + + return aRef; +} + + void SetWidth( wxString aStr, wxString aDefaultMeasurementUnit, int* aWidth, diff --git a/pcbnew/pcad2kicadpcb_plugin/pcad2kicad_common.h b/pcbnew/pcad2kicadpcb_plugin/pcad2kicad_common.h index 5d5a8127fb..02997e6b8f 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcad2kicad_common.h +++ b/pcbnew/pcad2kicadpcb_plugin/pcad2kicad_common.h @@ -71,6 +71,7 @@ extern wxString GetAndCutWordWithMeasureUnits( wxString* aStr, wxString aDefaultMeasurementUnit ); extern int StrToInt1Units( wxString aStr ); extern wxString ValidateName( wxString aName ); +extern wxString ValidateReference( wxString aRef ); extern void SetWidth( wxString aStr, wxString aDefaultMeasurementUnit, int* aWidth, diff --git a/pcbnew/pcad2kicadpcb_plugin/pcb_module.cpp b/pcbnew/pcad2kicadpcb_plugin/pcb_module.cpp index 849bcb048d..eeb73a5801 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcb_module.cpp +++ b/pcbnew/pcad2kicadpcb_plugin/pcb_module.cpp @@ -526,7 +526,7 @@ void PCB_MODULE::AddToBoard() // reference text TEXTE_MODULE* ref_text = &module->Reference(); - ref_text->SetText( m_name.text ); + ref_text->SetText( ValidateReference( m_name.text ) ); ref_text->SetType( TEXTE_MODULE::TEXT_is_REFERENCE ); ref_text->SetPos0( wxPoint( m_name.correctedPositionX, m_name.correctedPositionY ) );