7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 00:21:25 +00:00

API: Add serialization of footprint mounting style

See https://gitlab.com/kicad/code/kicad-python/-/issues/19
This commit is contained in:
Jon Evans 2025-02-20 17:46:23 -05:00
parent a8a1b08013
commit b932487f2e

View File

@ -310,6 +310,13 @@ void FOOTPRINT::Serialize( google::protobuf::Any &aContainer ) const
attrs->set_exempt_from_courtyard_requirement( AllowMissingCourtyard() );
attrs->set_do_not_populate( IsDNP() );
if( m_attributes & FP_THROUGH_HOLE )
attrs->set_mounting_style( types::FootprintMountingStyle::FMS_THROUGH_HOLE );
else if( m_attributes & FP_SMD )
attrs->set_mounting_style( types::FootprintMountingStyle::FMS_SMD );
else
attrs->set_mounting_style( types::FootprintMountingStyle::FMS_UNSPECIFIED );
types::Footprint* def = footprint.mutable_definition();
def->mutable_id()->CopyFrom( kiapi::common::LibIdToProto( GetFPID() ) );
@ -441,6 +448,22 @@ bool FOOTPRINT::Deserialize( const google::protobuf::Any &aContainer )
GetField( DESCRIPTION_FIELD )->Deserialize( buf );
}
m_attributes = 0;
switch( footprint.attributes().mounting_style() )
{
case types::FootprintMountingStyle::FMS_THROUGH_HOLE:
m_attributes |= FP_THROUGH_HOLE;
break;
case types::FootprintMountingStyle::FMS_SMD:
m_attributes |= FP_SMD;
break;
default:
break;
}
SetBoardOnly( footprint.attributes().not_in_schematic() );
SetExcludedFromBOM( footprint.attributes().exclude_from_bill_of_materials() );
SetExcludedFromPosFiles( footprint.attributes().exclude_from_position_files() );