diff --git a/pcbnew/python/swig/footprint.i b/pcbnew/python/swig/footprint.i index 8b970f84f3..80ee85f123 100644 --- a/pcbnew/python/swig/footprint.i +++ b/pcbnew/python/swig/footprint.i @@ -31,6 +31,7 @@ %template(MAP_STRING_STRING) std::map; %rename(GetPropertiesNative) FOOTPRINT::GetProperties; +%rename(GetPropertyNative) FOOTPRINT::GetProperty; %rename(SetPropertiesNative) FOOTPRINT::SetProperties; %rename(MODULE_3D_SETTINGS_VECTOR3D) MODULE_3D_SETTINGS::VECTOR3D; %feature("flatnested"); @@ -66,6 +67,13 @@ properties = self.GetPropertiesNative() return {str(k): str(v) for k, v in properties.items()} + def GetProperty(self, key): + """ Returns property with a given key if it exists, throws KeyError otherwise. """ + if self.HasProperty(key): + return self.GetPropertyNative(key) + else: + raise KeyError("Property not found: " + key) + def SetProperties(self, properties): """ Sets footprint properties map. """ wxproperties = MAP_STRING_STRING()