Browse Source

EasyEDA import: Add footprint Reference text on F_Fab.

9.0
Alex Shvartzkop 4 months ago
parent
commit
26b6c28bef
  1. 29
      pcbnew/pcb_io/easyeda/pcb_io_easyeda_parser.cpp
  2. 29
      pcbnew/pcb_io/easyedapro/pcb_io_easyedapro_parser.cpp

29
pcbnew/pcb_io/easyeda/pcb_io_easyeda_parser.cpp

@ -1136,6 +1136,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();
}

29
pcbnew/pcb_io/easyedapro/pcb_io_easyedapro_parser.cpp

@ -958,6 +958,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();
}

Loading…
Cancel
Save