diff --git a/include/core/typeinfo.h b/include/core/typeinfo.h index 4a2c005544..8784b686b2 100644 --- a/include/core/typeinfo.h +++ b/include/core/typeinfo.h @@ -332,6 +332,11 @@ constexpr bool IsInstantiableType( const KICAD_T aType ) case SCH_SYMBOL_LOCATE_POWER_T: + case PCB_FIELD_LOCATE_REFERENCE_T: + case PCB_FIELD_LOCATE_VALUE_T: + case PCB_FIELD_LOCATE_FOOTPRINT_T: + case PCB_FIELD_LOCATE_DATASHEET_T: + case PCB_LOCATE_STDVIA_T: case PCB_LOCATE_UVIA_T: case PCB_LOCATE_BBVIA_T: @@ -448,6 +453,10 @@ constexpr bool IsPcbnewType( const KICAD_T aType ) case PCB_NETINFO_T: case PCB_GROUP_T: + case PCB_FIELD_LOCATE_REFERENCE_T: + case PCB_FIELD_LOCATE_VALUE_T: + case PCB_FIELD_LOCATE_FOOTPRINT_T: + case PCB_FIELD_LOCATE_DATASHEET_T: case PCB_LOCATE_STDVIA_T: case PCB_LOCATE_UVIA_T: case PCB_LOCATE_BBVIA_T: diff --git a/pcbnew/python/swig/footprint.i b/pcbnew/python/swig/footprint.i index 5b32afc52e..0dcff19357 100644 --- a/pcbnew/python/swig/footprint.i +++ b/pcbnew/python/swig/footprint.i @@ -30,9 +30,8 @@ %template(MAP_STRING_STRING) std::map; -%rename(GetPropertiesNative) FOOTPRINT::GetProperties; -%rename(GetPropertyNative) FOOTPRINT::GetProperty; -%rename(SetPropertiesNative) FOOTPRINT::SetProperties; +%rename(GetFieldsNative) FOOTPRINT::GetFields; +%rename(SetFieldsNative) FOOTPRINT::SetFields; %feature("flatnested"); %include footprint.h %feature("flatnested", ""); @@ -61,24 +60,24 @@ # the object in the garbage collector # - def GetProperties(self): - """ Returns footprint properties map. """ - properties = self.GetPropertiesNative() - return {str(k): str(v) for k, v in properties.items()} + def GetFields(self): + """ Returns footprint fields map. """ + fields = self.GetFieldsNative() + return {str(k): str(v) for k, v in fields.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) + def GetField(self, key): + """ Returns Field with a given key if it exists, throws KeyError otherwise. """ + if self.HasField(key): + return self.GetFieldByName(key) else: - raise KeyError("Property not found: " + key) + raise KeyError("Field not found: " + key) - def SetProperties(self, properties): - """ Sets footprint properties map. """ - wxproperties = MAP_STRING_STRING() - for k, v in properties.items(): - wxproperties[k] = v - self.SetPropertiesNative(wxproperties) + def SetFields(self, fields): + """ Sets footprint fields map. """ + wxfields = MAP_STRING_STRING() + for k, v in fields.items(): + wxfields[k] = v + self.SetFieldsNative(wxfields) %} } diff --git a/qa/tests/pcbnewswig/test_002_board_class.py b/qa/tests/pcbnewswig/test_002_board_class.py index f7de6e6e6a..035c3afb56 100644 --- a/qa/tests/pcbnewswig/test_002_board_class.py +++ b/qa/tests/pcbnewswig/test_002_board_class.py @@ -123,15 +123,15 @@ class TestBoardClass: def test_footprint_properties(self): pcb = LoadBoard("../data/pcbnew/custom_fields.kicad_pcb") footprint = pcb.FindFootprintByReference('J1') - expected_properties = { + expected_fields = { 'Sheet file': 'custom_fields.kicad_sch', 'Sheet name': '', 'myfield': 'myvalue' } - assert footprint.GetProperties() == expected_properties - assert footprint.GetProperty('myfield') == 'myvalue' - assert footprint.HasProperty('myfield') == True - assert footprint.HasProperty('abcd') == False - footprint.SetProperty('abcd', 'efgh') - assert footprint.HasProperty('abcd') == True - assert footprint.GetProperty('abcd') == 'efgh' + assert footprint.GetFields() == expected_fields + assert footprint.GetField('myfield') == 'myvalue' + assert footprint.HasField('myfield') == True + assert footprint.HasField('abcd') == False + footprint.SetField('abcd', 'efgh') + assert footprint.HasField('abcd') == True + assert footprint.GetField('abcd') == 'efgh'