EasyEDA import: Add footprint Reference text on F_Fab.

(cherry picked from commit 26b6c28befdfbcd0978794977e98186d720d97f5)

Co-authored-by: Alex Shvartzkop <dudesuchamazing@gmail.com>
This commit is contained in:
dsa-t 2025-08-21 17:41:09 +03:00
parent 3e58b34843
commit 66a1e268d7
2 changed files with 58 additions and 0 deletions

View File

@ -1134,6 +1134,35 @@ FOOTPRINT* PCB_IO_EASYEDA_PARSER::ParseFootprint(
footprint->Add( shape.release(), ADD_MODE::APPEND );
}
bool hasFabRef = false;
for( BOARD_ITEM* item : footprint->GraphicalItems() )
{
if( item->Type() == PCB_TEXT_T && item->IsOnLayer( F_Fab ) )
{
if( static_cast<PCB_TEXT*>( item )->GetText() == wxT( "${REFERENCE}" ) )
{
hasFabRef = true;
break;
}
}
}
if( !hasFabRef )
{
// Add reference text field on F_Fab
int c_refTextSize = pcbIUScale.mmToIU( 0.5 ); // KLC min Fab text size
int c_refTextThickness = pcbIUScale.mmToIU( 0.1 ); // Decent text thickness
std::unique_ptr<PCB_TEXT> refText = std::make_unique<PCB_TEXT>( footprint.get() );
refText->SetLayer( F_Fab );
refText->SetTextSize( VECTOR2I( c_refTextSize, c_refTextSize ) );
refText->SetTextThickness( c_refTextThickness );
refText->SetText( wxT( "${REFERENCE}" ) );
footprint->Add( refText.release(), ADD_MODE::APPEND );
}
return footprint.release();
}

View File

@ -959,6 +959,35 @@ FOOTPRINT* PCB_IO_EASYEDAPRO_PARSER::ParseFootprint( const nlohmann::json&
footprint->Add( shape.release(), ADD_MODE::APPEND );
}
bool hasFabRef = false;
for( BOARD_ITEM* item : footprint->GraphicalItems() )
{
if( item->Type() == PCB_TEXT_T && item->IsOnLayer( F_Fab ) )
{
if( static_cast<PCB_TEXT*>( item )->GetText() == wxT( "${REFERENCE}" ) )
{
hasFabRef = true;
break;
}
}
}
if( !hasFabRef )
{
// Add reference text field on F_Fab
int c_refTextSize = pcbIUScale.mmToIU( 0.5 ); // KLC min Fab text size
int c_refTextThickness = pcbIUScale.mmToIU( 0.1 ); // Decent text thickness
std::unique_ptr<PCB_TEXT> refText = std::make_unique<PCB_TEXT>( footprint );
refText->SetLayer( F_Fab );
refText->SetTextSize( VECTOR2I( c_refTextSize, c_refTextSize ) );
refText->SetTextThickness( c_refTextThickness );
refText->SetText( wxT( "${REFERENCE}" ) );
footprint->Add( refText.release(), ADD_MODE::APPEND );
}
return footprintPtr.release();
}