Make footprint properties accessible from python

Now that footprint properties inherit custom fields from schematic
they are very useful.

Setting custom properties from python will also be handy in plugins
that need to somehow mark their own objects.
This commit is contained in:
qu1ck 2021-01-24 21:51:44 -08:00
parent 2e67cd2db8
commit 5c3ee0443c
7 changed files with 796 additions and 1 deletions

View File

@ -826,7 +826,7 @@ if( KICAD_SCRIPTING_MODULES )
# Here is built the _pcbnew.{so,pyd} which is the native part of the pcbnew Python library
# when Python is used from the command line.
if( MINGW )
if( MINGW OR VCPKG_TOOLCHAIN )
install( FILES ${CMAKE_BINARY_DIR}/pcbnew/_pcbnew.pyd DESTINATION ${PYTHON_DEST} )
set( PYMOD_EXT "pyd" )
elseif( APPLE )

View File

@ -493,6 +493,12 @@ public:
const std::map<wxString, wxString>& GetProperties() const { return m_properties; }
void SetProperties( const std::map<wxString, wxString>& aProps ) { m_properties = aProps; }
const wxString& GetProperty( const wxString& aKey) { return m_properties[ aKey ]; }
bool HasProperty( const wxString& aKey)
{
return m_properties.find( aKey ) != m_properties.end();
}
void SetProperty( const wxString& aKey, const wxString& aVal ) { m_properties[ aKey ] = aVal; }
/**
* Return a #PAD with a matching name.

View File

@ -29,6 +29,9 @@
*/
%template(MAP_STRING_STRING) std::map<wxString, wxString>;
%rename(GetPropertiesNative) FOOTPRINT::GetProperties;
%rename(SetPropertiesNative) FOOTPRINT::SetProperties;
%rename(MODULE_3D_SETTINGS_VECTOR3D) MODULE_3D_SETTINGS::VECTOR3D;
%feature("flatnested");
%include footprint.h
@ -57,6 +60,19 @@
# add function, clears the thisown to avoid python from deleting
# 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 SetProperties(self, properties):
""" Sets footprint properties map. """
wxproperties = MAP_STRING_STRING()
for k, v in properties.items():
wxproperties[k] = v
self.SetPropertiesNative(wxproperties)
%}
}

View File

@ -0,0 +1,197 @@
(kicad_pcb (version 20210108) (generator pcbnew)
(general
(thickness 1.6)
)
(paper "A4")
(layers
(0 "F.Cu" signal)
(31 "B.Cu" signal)
(32 "B.Adhes" user "B.Adhesive")
(33 "F.Adhes" user "F.Adhesive")
(34 "B.Paste" user)
(35 "F.Paste" user)
(36 "B.SilkS" user "B.Silkscreen")
(37 "F.SilkS" user "F.Silkscreen")
(38 "B.Mask" user)
(39 "F.Mask" user)
(40 "Dwgs.User" user "User.Drawings")
(41 "Cmts.User" user "User.Comments")
(42 "Eco1.User" user "User.Eco1")
(43 "Eco2.User" user "User.Eco2")
(44 "Edge.Cuts" user)
(45 "Margin" user)
(46 "B.CrtYd" user "B.Courtyard")
(47 "F.CrtYd" user "F.Courtyard")
(48 "B.Fab" user)
(49 "F.Fab" user)
(50 "User.1" user)
(51 "User.2" user)
(52 "User.3" user)
(53 "User.4" user)
(54 "User.5" user)
(55 "User.6" user)
(56 "User.7" user)
(57 "User.8" user)
(58 "User.9" user)
)
(setup
(pcbplotparams
(layerselection 0x00010fc_ffffffff)
(disableapertmacros false)
(usegerberextensions false)
(usegerberattributes true)
(usegerberadvancedattributes true)
(creategerberjobfile true)
(svguseinch false)
(svgprecision 6)
(excludeedgelayer true)
(plotframeref false)
(viasonmask false)
(mode 1)
(useauxorigin false)
(hpglpennumber 1)
(hpglpenspeed 20)
(hpglpendiameter 15.000000)
(dxfpolygonmode true)
(dxfimperialunits true)
(dxfusepcbnewfont true)
(psnegative false)
(psa4output false)
(plotreference true)
(plotvalue true)
(plotinvisibletext false)
(sketchpadsonfab false)
(subtractmaskfromsilk false)
(outputformat 1)
(mirror false)
(drillshape 1)
(scaleselection 1)
(outputdirectory "")
)
)
(net 0 "")
(net 1 "Net-(J1-Pad2)")
(net 2 "Net-(J1-Pad1)")
(footprint "Connector_JST:JST_XH_B2B-XH-A_1x02_P2.50mm_Vertical" (layer "F.Cu")
(tedit 5C28146C) (tstamp 31e64d6a-f88c-4e7b-96a7-e658bb2d65e4)
(at 52.5 42 90)
(descr "JST XH series connector, B2B-XH-A (http://www.jst-mfg.com/product/pdf/eng/eXH.pdf), generated with kicad-footprint-generator")
(tags "connector JST XH vertical")
(property "Sheet file" "custom_fields.kicad_sch")
(property "Sheet name" "")
(property "myfield" "myvalue")
(path "/ebd12d3c-779b-42b9-beee-e5481760d2bb")
(attr through_hole)
(fp_text reference "J1" (at 1.25 -3.55 90) (layer "F.SilkS")
(effects (font (size 1 1) (thickness 0.15)))
(tstamp b6b88516-7510-4e2b-b332-a7c293fb9645)
)
(fp_text value "Conn_01x02" (at 1.25 4.6 90) (layer "F.Fab")
(effects (font (size 1 1) (thickness 0.15)))
(tstamp a949b776-c13a-4425-bf31-94a1e499d3e7)
)
(fp_text user "${REFERENCE}" (at 1.25 2.7 90) (layer "F.Fab")
(effects (font (size 1 1) (thickness 0.15)))
(tstamp 70d1b18d-ebc6-4d7d-b051-de393c9c5790)
)
(fp_line (start -1.6 -2.75) (end -2.85 -2.75) (layer "F.SilkS") (width 0.12) (tstamp 0f534c9b-0a91-4969-9309-45f61a9341d6))
(fp_line (start -2.55 -2.45) (end -2.55 -1.7) (layer "F.SilkS") (width 0.12) (tstamp 110aa54f-3431-4803-afd4-78666d197d59))
(fp_line (start 1.75 -1.7) (end 1.75 -2.45) (layer "F.SilkS") (width 0.12) (tstamp 22635c7f-530a-4bd5-a3ba-0b932d2b7a8e))
(fp_line (start -1.8 2.75) (end 1.25 2.75) (layer "F.SilkS") (width 0.12) (tstamp 24927c20-7889-4ca5-9cc8-d411b78de981))
(fp_line (start 0.75 -1.7) (end 1.75 -1.7) (layer "F.SilkS") (width 0.12) (tstamp 2b296b29-3a61-4d84-bcdf-2ee852b5885c))
(fp_line (start 3.25 -1.7) (end 5.05 -1.7) (layer "F.SilkS") (width 0.12) (tstamp 30090ea5-5ed9-4cf4-a6ad-06884ad92d1e))
(fp_line (start 4.3 -0.2) (end 4.3 2.75) (layer "F.SilkS") (width 0.12) (tstamp 361637c0-78f9-49af-8ff5-1f6c02f490ae))
(fp_line (start 5.05 -1.7) (end 5.05 -2.45) (layer "F.SilkS") (width 0.12) (tstamp 43356761-9fe4-48ba-880d-5d51f6c221ba))
(fp_line (start -0.75 -1.7) (end -0.75 -2.45) (layer "F.SilkS") (width 0.12) (tstamp 4556a23d-ff3f-4a29-abce-38831c92b9ad))
(fp_line (start 5.05 -0.2) (end 4.3 -0.2) (layer "F.SilkS") (width 0.12) (tstamp 555654e4-620f-489f-a83c-a8c1fd452476))
(fp_line (start -1.8 -0.2) (end -1.8 2.75) (layer "F.SilkS") (width 0.12) (tstamp 5c88ada0-5166-41c3-93c1-f3864cd19a8c))
(fp_line (start 3.25 -2.45) (end 3.25 -1.7) (layer "F.SilkS") (width 0.12) (tstamp 77e1b960-bc10-424f-9993-dfe73bde83ff))
(fp_line (start 1.75 -2.45) (end 0.75 -2.45) (layer "F.SilkS") (width 0.12) (tstamp 7ec93feb-f270-4cda-af66-9992fcb00e17))
(fp_line (start -2.85 -2.75) (end -2.85 -1.5) (layer "F.SilkS") (width 0.12) (tstamp 848abbfe-dfd1-44f6-b4d4-0444a2093e55))
(fp_line (start 4.3 2.75) (end 1.25 2.75) (layer "F.SilkS") (width 0.12) (tstamp 9976a5a8-d260-4fd0-89a7-0de10d1674aa))
(fp_line (start 5.06 -2.46) (end -2.56 -2.46) (layer "F.SilkS") (width 0.12) (tstamp a0504731-78b8-4927-93e2-973ee7b0fce9))
(fp_line (start -2.55 -1.7) (end -0.75 -1.7) (layer "F.SilkS") (width 0.12) (tstamp ad89f516-021b-41f8-ba70-4dd88f7a2a76))
(fp_line (start -0.75 -2.45) (end -2.55 -2.45) (layer "F.SilkS") (width 0.12) (tstamp b8492a3e-bcd6-47db-8695-76605c952304))
(fp_line (start 0.75 -2.45) (end 0.75 -1.7) (layer "F.SilkS") (width 0.12) (tstamp d66d0a92-1f3b-4549-8c1e-105073b8d741))
(fp_line (start 5.06 3.51) (end 5.06 -2.46) (layer "F.SilkS") (width 0.12) (tstamp dd9f9cd4-cd85-486c-ae3d-ace52e68efca))
(fp_line (start -2.56 3.51) (end 5.06 3.51) (layer "F.SilkS") (width 0.12) (tstamp e66d32ed-55c3-4517-bf9c-6589ec46d468))
(fp_line (start -2.56 -2.46) (end -2.56 3.51) (layer "F.SilkS") (width 0.12) (tstamp e9b36eaa-028a-4390-b11b-5d56cc12ee95))
(fp_line (start 5.05 -2.45) (end 3.25 -2.45) (layer "F.SilkS") (width 0.12) (tstamp ee5543eb-ef6e-4a08-b56b-63ab234eda71))
(fp_line (start -2.55 -0.2) (end -1.8 -0.2) (layer "F.SilkS") (width 0.12) (tstamp ee991bb5-ed70-4547-8387-25d824486ade))
(fp_line (start 5.45 -2.85) (end -2.95 -2.85) (layer "F.CrtYd") (width 0.05) (tstamp a222a447-a6af-4db5-b424-1b543ddbcb9b))
(fp_line (start -2.95 3.9) (end 5.45 3.9) (layer "F.CrtYd") (width 0.05) (tstamp bb760712-b2bd-47ad-ac13-669e5ca84f0e))
(fp_line (start -2.95 -2.85) (end -2.95 3.9) (layer "F.CrtYd") (width 0.05) (tstamp f7ee289f-83be-4549-8ad8-88f1fa82a554))
(fp_line (start 5.45 3.9) (end 5.45 -2.85) (layer "F.CrtYd") (width 0.05) (tstamp fd2f6b84-6286-49d5-b1c7-f132880f6eb9))
(fp_line (start 4.95 3.4) (end 4.95 -2.35) (layer "F.Fab") (width 0.1) (tstamp 22ab8453-ea7f-4b04-adb8-447d2eb85b68))
(fp_line (start -2.45 -2.35) (end -2.45 3.4) (layer "F.Fab") (width 0.1) (tstamp 32bc7022-04d2-4e1e-b7ea-fcd2069ba2f1))
(fp_line (start 4.95 -2.35) (end -2.45 -2.35) (layer "F.Fab") (width 0.1) (tstamp 4fe668a3-9715-4fe1-874a-dfbf96879c5d))
(fp_line (start -2.45 3.4) (end 4.95 3.4) (layer "F.Fab") (width 0.1) (tstamp 51babf02-d4f7-43f4-bc5d-7354e076dadb))
(fp_line (start 0 -1.35) (end 0.625 -2.35) (layer "F.Fab") (width 0.1) (tstamp 60010bc0-81ce-4b9e-9c37-3b033eb01867))
(fp_line (start -0.625 -2.35) (end 0 -1.35) (layer "F.Fab") (width 0.1) (tstamp ff0906c6-6d91-41be-9b52-409424d48b1e))
(pad "1" thru_hole roundrect (at 0 0 90) (locked) (size 1.7 2) (drill 1) (layers *.Cu *.Mask) (roundrect_rratio 0.147059)
(net 2 "Net-(J1-Pad1)") (pinfunction "Pin_1") (tstamp 845a77c2-2015-4d97-9fa8-e592765a5c33))
(pad "2" thru_hole oval (at 2.5 0 90) (locked) (size 1.7 2) (drill 1) (layers *.Cu *.Mask)
(net 1 "Net-(J1-Pad2)") (pinfunction "Pin_2") (tstamp d22edf36-c03c-478e-a168-5316b5c211e7))
(model "${KISYS3DMOD}/Connector_JST.3dshapes/JST_XH_B2B-XH-A_1x02_P2.50mm_Vertical.wrl"
(offset (xyz 0 0 0))
(scale (xyz 1 1 1))
(rotate (xyz 0 0 0))
)
)
(footprint "Resistor_SMD:R_1206_3216Metric" (layer "F.Cu")
(tedit 5F68FEEE) (tstamp 42777b9c-6a01-47f9-94ba-51a18313ba4c)
(at 43 40.5 90)
(descr "Resistor SMD 1206 (3216 Metric), square (rectangular) end terminal, IPC_7351 nominal, (Body size source: IPC-SM-782 page 72, https://www.pcb-3d.com/wordpress/wp-content/uploads/ipc-sm-782a_amendment_1_and_2.pdf), generated with kicad-footprint-generator")
(tags "resistor")
(property "Sheet file" "custom_fields.kicad_sch")
(property "Sheet name" "")
(path "/8e574303-eef9-471f-8bf9-dbda319f7a68")
(attr smd)
(fp_text reference "R1" (at 0 -1.82 90) (layer "F.SilkS")
(effects (font (size 1 1) (thickness 0.15)))
(tstamp f78de4b0-781e-409b-910c-31682973faa2)
)
(fp_text value "R" (at 0 1.82 90) (layer "F.Fab")
(effects (font (size 1 1) (thickness 0.15)))
(tstamp 2ddf1359-0e6e-4e01-a10c-2ce17e66e203)
)
(fp_text user "${REFERENCE}" (at 0 0 90) (layer "F.Fab")
(effects (font (size 0.8 0.8) (thickness 0.12)))
(tstamp 3076e368-6c46-44bf-bc1c-0c0292ae045f)
)
(fp_line (start -0.727064 0.91) (end 0.727064 0.91) (layer "F.SilkS") (width 0.12) (tstamp 77ef7d67-7b93-4b90-bc3f-dc27f264711d))
(fp_line (start -0.727064 -0.91) (end 0.727064 -0.91) (layer "F.SilkS") (width 0.12) (tstamp e4821c9f-ebc7-4f41-a572-11aa9374c0ab))
(fp_line (start -2.28 1.12) (end -2.28 -1.12) (layer "F.CrtYd") (width 0.05) (tstamp 93ed1c40-a8a6-4bcd-9873-c17803b043a6))
(fp_line (start -2.28 -1.12) (end 2.28 -1.12) (layer "F.CrtYd") (width 0.05) (tstamp c00b6509-2c25-4c51-b785-6f1fedf39d81))
(fp_line (start 2.28 1.12) (end -2.28 1.12) (layer "F.CrtYd") (width 0.05) (tstamp c8234048-34e9-46a3-b381-37f7a36486b4))
(fp_line (start 2.28 -1.12) (end 2.28 1.12) (layer "F.CrtYd") (width 0.05) (tstamp e996ab65-3fc8-465d-ba56-f0f00a67f469))
(fp_line (start 1.6 -0.8) (end 1.6 0.8) (layer "F.Fab") (width 0.1) (tstamp 11aad42c-b045-4351-b078-e887c6ee4169))
(fp_line (start -1.6 -0.8) (end 1.6 -0.8) (layer "F.Fab") (width 0.1) (tstamp 481ca6c9-4e09-4c4b-a019-1d2dda5e367a))
(fp_line (start 1.6 0.8) (end -1.6 0.8) (layer "F.Fab") (width 0.1) (tstamp ca9c1be4-ffd6-4a8e-9e97-a5e472b24c46))
(fp_line (start -1.6 0.8) (end -1.6 -0.8) (layer "F.Fab") (width 0.1) (tstamp d9f34d44-5fa8-45cb-839b-a7c1ceb05fe5))
(pad "1" smd roundrect (at -1.4625 0 90) (locked) (size 1.125 1.75) (layers "F.Cu" "F.Paste" "F.Mask") (roundrect_rratio 0.222222)
(net 2 "Net-(J1-Pad1)") (tstamp caa680db-7ecc-4415-9047-7ebf1db6c37d))
(pad "2" smd roundrect (at 1.4625 0 90) (locked) (size 1.125 1.75) (layers "F.Cu" "F.Paste" "F.Mask") (roundrect_rratio 0.222222)
(net 1 "Net-(J1-Pad2)") (tstamp 556913fa-a365-4e6c-a386-b90179196bf5))
(model "${KISYS3DMOD}/Resistor_SMD.3dshapes/R_1206_3216Metric.wrl"
(offset (xyz 0 0 0))
(scale (xyz 1 1 1))
(rotate (xyz 0 0 0))
)
)
(gr_rect (start 33.5 29.5) (end 63.5 51.5) (layer "Edge.Cuts") (width 0.1) (fill none) (tstamp 76cd25fa-0255-4837-b713-ce8b1dcf8052))
(segment (start 52.0375 39.0375) (end 52.5 39.5) (width 0.25) (layer "F.Cu") (net 1) (tstamp 51a03e08-df30-4395-b451-95697ed9917e))
(segment (start 43 39.0375) (end 52.0375 39.0375) (width 0.25) (layer "F.Cu") (net 1) (tstamp 82e97b8a-3862-49e4-a678-f30791e9fcd9))
(segment (start 52.4625 41.9625) (end 52.5 42) (width 0.25) (layer "F.Cu") (net 2) (tstamp 37d59dca-a894-4e1b-9385-41dd57050f93))
(segment (start 43 41.9625) (end 52.4625 41.9625) (width 0.25) (layer "F.Cu") (net 2) (tstamp 7734a9d2-e525-47ca-9435-3f8279f2e5e8))
)

View File

@ -0,0 +1,409 @@
{
"board": {
"design_settings": {
"defaults": {
"board_outline_line_width": 0.09999999999999999,
"copper_line_width": 0.19999999999999998,
"copper_text_italic": false,
"copper_text_size_h": 1.5,
"copper_text_size_v": 1.5,
"copper_text_thickness": 0.3,
"copper_text_upright": false,
"courtyard_line_width": 0.049999999999999996,
"dimension_precision": 4,
"dimension_units": 3,
"dimensions": {
"arrow_length": 1270000,
"extension_offset": 500000,
"keep_text_aligned": true,
"suppress_zeroes": false,
"text_position": 0,
"units_format": 1
},
"fab_line_width": 0.09999999999999999,
"fab_text_italic": false,
"fab_text_size_h": 1.0,
"fab_text_size_v": 1.0,
"fab_text_thickness": 0.15,
"fab_text_upright": false,
"other_line_width": 0.15,
"other_text_italic": false,
"other_text_size_h": 1.0,
"other_text_size_v": 1.0,
"other_text_thickness": 0.15,
"other_text_upright": false,
"pads": {
"drill": 0.762,
"height": 1.524,
"width": 1.524
},
"silk_line_width": 0.15,
"silk_text_italic": false,
"silk_text_size_h": 1.0,
"silk_text_size_v": 1.0,
"silk_text_thickness": 0.15,
"silk_text_upright": false,
"zones": {
"45_degree_only": false,
"min_clearance": 0.508
}
},
"diff_pair_dimensions": [],
"drc_exclusions": [],
"meta": {
"version": 1
},
"rule_severities": {
"annular_width": "error",
"clearance": "error",
"copper_edge_clearance": "error",
"courtyards_overlap": "error",
"diff_pair_gap_out_of_range": "error",
"diff_pair_uncoupled_length_too_long": "error",
"drill_out_of_range": "error",
"duplicate_footprints": "warning",
"extra_footprint": "warning",
"hole_clearance": "error",
"hole_near_hole": "error",
"invalid_outline": "error",
"item_on_disabled_layer": "error",
"items_not_allowed": "error",
"length_out_of_range": "error",
"malformed_courtyard": "error",
"microvia_drill_out_of_range": "error",
"missing_courtyard": "ignore",
"missing_footprint": "warning",
"net_conflict": "warning",
"npth_inside_courtyard": "ignore",
"padstack": "error",
"pth_inside_courtyard": "ignore",
"shorting_items": "error",
"silk_over_copper": "error",
"silk_overlap": "error",
"skew_out_of_range": "error",
"too_many_vias": "error",
"track_dangling": "warning",
"track_width": "error",
"tracks_crossing": "error",
"unconnected_items": "error",
"unresolved_variable": "error",
"via_dangling": "warning",
"zone_has_empty_net": "error",
"zones_intersect": "error"
},
"rules": {
"allow_blind_buried_vias": false,
"allow_microvias": false,
"max_error": 0.005,
"min_clearance": 0.0,
"min_copper_edge_clearance": 0.0,
"min_hole_clearance": 0.0,
"min_hole_to_hole": 0.25,
"min_microvia_diameter": 0.19999999999999998,
"min_microvia_drill": 0.09999999999999999,
"min_silk_clearance": 0.0,
"min_through_hole_diameter": 0.3,
"min_track_width": 0.19999999999999998,
"min_via_annular_width": 0.049999999999999996,
"min_via_diameter": 0.39999999999999997,
"solder_mask_clearance": 0.0,
"solder_mask_min_width": 0.0,
"solder_paste_clearance": 0.0,
"solder_paste_margin_ratio": 0.0
},
"track_widths": [],
"via_dimensions": [],
"zones_allow_external_fillets": false,
"zones_use_no_outline": true
},
"layer_presets": []
},
"boards": [],
"cvpcb": {
"equivalence_files": []
},
"erc": {
"erc_exclusions": [],
"meta": {
"version": 0
},
"pin_map": [
[
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
2
],
[
0,
2,
0,
1,
0,
0,
1,
0,
2,
2,
2,
2
],
[
0,
0,
0,
0,
0,
0,
1,
0,
1,
0,
1,
2
],
[
0,
1,
0,
0,
0,
0,
1,
1,
2,
1,
1,
2
],
[
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
2
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
2
],
[
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
2
],
[
0,
0,
0,
1,
0,
0,
1,
0,
0,
0,
0,
2
],
[
0,
2,
1,
2,
0,
0,
1,
0,
2,
2,
2,
2
],
[
0,
2,
0,
1,
0,
0,
1,
0,
2,
0,
0,
2
],
[
0,
2,
1,
1,
0,
0,
1,
0,
2,
0,
0,
2
],
[
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2
]
],
"rule_severities": {
"bus_definition_conflict": "error",
"bus_label_syntax": "error",
"bus_to_bus_conflict": "error",
"bus_to_net_conflict": "error",
"different_unit_footprint": "error",
"different_unit_net": "error",
"duplicate_reference": "error",
"duplicate_sheet_names": "error",
"extra_units": "error",
"global_label_dangling": "warning",
"hier_label_mismatch": "error",
"label_dangling": "error",
"lib_symbol_issues": "warning",
"multiple_net_names": "warning",
"net_not_bus_member": "warning",
"no_connect_connected": "warning",
"no_connect_dangling": "warning",
"pin_not_connected": "error",
"pin_not_driven": "error",
"pin_to_pin": "warning",
"power_pin_not_driven": "error",
"similar_labels": "warning",
"unannotated": "error",
"unit_value_mismatch": "error",
"unresolved_variable": "error",
"wire_dangling": "error"
}
},
"libraries": {
"pinned_footprint_libs": [],
"pinned_symbol_libs": []
},
"meta": {
"filename": "custom_fields.kicad_pro",
"version": 1
},
"net_settings": {
"classes": [
{
"bus_width": 6.0,
"clearance": 0.2,
"diff_pair_gap": 0.25,
"diff_pair_via_gap": 0.25,
"diff_pair_width": 0.2,
"line_style": 0,
"microvia_diameter": 0.3,
"microvia_drill": 0.1,
"name": "Default",
"pcb_color": "rgba(0, 0, 0, 0.000)",
"schematic_color": "rgba(0, 0, 0, 0.000)",
"track_width": 0.25,
"via_diameter": 0.8,
"via_drill": 0.4,
"wire_width": 6.0
}
],
"meta": {
"version": 0
},
"net_colors": null
},
"pcbnew": {
"last_paths": {
"gencad": "",
"idf": "",
"netlist": "",
"specctra_dsn": "",
"step": "",
"vrml": ""
},
"page_layout_descr_file": ""
},
"schematic": {
"drawing": {
"default_bus_thickness": 12.0,
"default_junction_size": 40.0,
"default_line_thickness": 6.0,
"default_text_size": 50.0,
"default_wire_thickness": 6.0,
"field_names": [],
"intersheets_ref_prefix": "",
"intersheets_ref_short": false,
"intersheets_ref_show": false,
"intersheets_ref_suffix": "",
"junction_size_choice": 3,
"pin_symbol_size": 25.0,
"text_offset_ratio": 0.3
},
"legacy_lib_dir": "",
"legacy_lib_list": [],
"meta": {
"version": 0
},
"net_format_name": "",
"page_layout_descr_file": "",
"plot_directory": "",
"spice_adjust_passive_values": false,
"spice_external_command": "spice \"%I\"",
"subpart_first_id": 65,
"subpart_id_separator": 0
},
"sheets": [
[
"48feb7be-17c7-4e45-9b9c-10d12015bb0e",
""
]
],
"text_variables": {}
}

View File

@ -0,0 +1,151 @@
(kicad_sch (version 20210123) (generator eeschema)
(paper "A4")
(lib_symbols
(symbol "Connector_Generic:Conn_01x02" (pin_names (offset 1.016) hide) (in_bom yes) (on_board yes)
(property "Reference" "J" (id 0) (at 0 2.54 0)
(effects (font (size 1.27 1.27)))
)
(property "Value" "Conn_01x02" (id 1) (at 0 -5.08 0)
(effects (font (size 1.27 1.27)))
)
(property "Footprint" "" (id 2) (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "~" (id 3) (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "ki_keywords" "connector" (id 4) (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "ki_description" "Generic connector, single row, 01x02, script generated (kicad-library-utils/schlib/autogen/connector/)" (id 5) (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "ki_fp_filters" "Connector*:*_1x??_*" (id 6) (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(symbol "Conn_01x02_1_1"
(rectangle (start -1.27 -2.413) (end 0 -2.667)
(stroke (width 0.1524)) (fill (type none))
)
(rectangle (start -1.27 0.127) (end 0 -0.127)
(stroke (width 0.1524)) (fill (type none))
)
(rectangle (start -1.27 1.27) (end 1.27 -3.81)
(stroke (width 0.254)) (fill (type background))
)
(pin passive line (at -5.08 0 0) (length 3.81)
(name "Pin_1" (effects (font (size 1.27 1.27))))
(number "1" (effects (font (size 1.27 1.27))))
)
(pin passive line (at -5.08 -2.54 0) (length 3.81)
(name "Pin_2" (effects (font (size 1.27 1.27))))
(number "2" (effects (font (size 1.27 1.27))))
)
)
)
(symbol "Device:R" (pin_numbers hide) (pin_names (offset 0)) (in_bom yes) (on_board yes)
(property "Reference" "R" (id 0) (at 2.032 0 90)
(effects (font (size 1.27 1.27)))
)
(property "Value" "R" (id 1) (at 0 0 90)
(effects (font (size 1.27 1.27)))
)
(property "Footprint" "" (id 2) (at -1.778 0 90)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "~" (id 3) (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "ki_keywords" "R res resistor" (id 4) (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "ki_description" "Resistor" (id 5) (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "ki_fp_filters" "R_*" (id 6) (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(symbol "R_0_1"
(rectangle (start -1.016 -2.54) (end 1.016 2.54)
(stroke (width 0.254)) (fill (type none))
)
)
(symbol "R_1_1"
(pin passive line (at 0 3.81 270) (length 1.27)
(name "~" (effects (font (size 1.27 1.27))))
(number "1" (effects (font (size 1.27 1.27))))
)
(pin passive line (at 0 -3.81 90) (length 1.27)
(name "~" (effects (font (size 1.27 1.27))))
(number "2" (effects (font (size 1.27 1.27))))
)
)
)
)
(wire (pts (xy 125.73 90.17) (xy 142.24 90.17))
(stroke (width 0) (type solid) (color 0 0 0 0))
)
(wire (pts (xy 142.24 90.17) (xy 142.24 92.71))
(stroke (width 0) (type solid) (color 0 0 0 0))
)
(wire (pts (xy 142.24 95.25) (xy 142.24 97.79))
(stroke (width 0) (type solid) (color 0 0 0 0))
)
(wire (pts (xy 142.24 97.79) (xy 125.73 97.79))
(stroke (width 0) (type solid) (color 0 0 0 0))
)
(symbol (lib_id "Device:R") (at 125.73 93.98 0) (unit 1)
(in_bom yes) (on_board yes)
(uuid "8e574303-eef9-471f-8bf9-dbda319f7a68")
(property "Reference" "R1" (id 0) (at 127.5081 92.8306 0)
(effects (font (size 1.27 1.27)) (justify left))
)
(property "Value" "R" (id 1) (at 127.5081 95.1293 0)
(effects (font (size 1.27 1.27)) (justify left))
)
(property "Footprint" "Resistor_SMD:R_1206_3216Metric" (id 2) (at 123.952 93.98 90)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "~" (id 3) (at 125.73 93.98 0)
(effects (font (size 1.27 1.27)) hide)
)
)
(symbol (lib_id "Connector_Generic:Conn_01x02") (at 147.32 92.71 0) (unit 1)
(in_bom yes) (on_board yes)
(uuid "ebd12d3c-779b-42b9-beee-e5481760d2bb")
(property "Reference" "J1" (id 0) (at 149.3521 92.8814 0)
(effects (font (size 1.27 1.27)) (justify left))
)
(property "Value" "Conn_01x02" (id 1) (at 149.3521 95.1801 0)
(effects (font (size 1.27 1.27)) (justify left))
)
(property "Footprint" "Connector_JST:JST_XH_B2B-XH-A_1x02_P2.50mm_Vertical" (id 2) (at 147.32 92.71 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "~" (id 3) (at 147.32 92.71 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "myfield" "myvalue" (id 4) (at 147.32 92.71 0)
(effects (font (size 1.27 1.27)) hide)
)
)
(sheet_instances
(path "/" (page "1"))
)
(symbol_instances
(path "/ebd12d3c-779b-42b9-beee-e5481760d2bb"
(reference "J1") (unit 1) (value "Conn_01x02") (footprint "Connector_JST:JST_XH_B2B-XH-A_1x02_P2.50mm_Vertical")
)
(path "/8e574303-eef9-471f-8bf9-dbda319f7a68"
(reference "R1") (unit 1) (value "R") (footprint "Resistor_SMD:R_1206_3216Metric")
)
)
)

View File

@ -125,6 +125,22 @@ class TestBoardClass(unittest.TestCase):
# ensure we can get to the ID via the STD name too
self.assertEqual(pcb.GetLayerID(B_CU), b_cu_id)
def test_footprint_properties(self):
pcb = LoadBoard("data/custom_fields.kicad_pcb")
footprint = pcb.FindFootprintByReference('J1')
expected_properties = {
'Sheet file': 'custom_fields.kicad_sch',
'Sheet name': '',
'myfield': 'myvalue'
}
self.assertEquals(footprint.GetProperties(), expected_properties)
self.assertEquals(footprint.GetProperty('myfield'), 'myvalue')
self.assertEquals(footprint.HasProperty('myfield'), True)
self.assertEquals(footprint.HasProperty('abcd'), False)
footprint.SetProperty('abcd', 'efgh')
self.assertEquals(footprint.HasProperty('abcd'), True)
self.assertEquals(footprint.GetProperty('abcd'), 'efgh')
#def test_interactive(self):
# code.interact(local=locals())