diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..a7b0016 Binary files /dev/null and b/.DS_Store differ diff --git a/README.md b/README.md index 87fcf03..e54ca94 100644 --- a/README.md +++ b/README.md @@ -133,7 +133,15 @@ _The fields will be queried in the order denoted above._ _The fields will be queried in the order denoted above._ -### ⑤ Override Component Layer +### ⑤ Override Component Origin +The Fabrication Toolkit reports the position of each component based on an automatically selected point of reference. This default behavior can be overridden by adding an **Origin** field to the component. + +The **Origin** field supports the following values: + +- `Anchor` - Uses the footprint's anchor point, which can be modified in KiCad's footprint editor. +- `Center` - Uses the center of the bounding box formed by the footprint's pads. + +### ⑥ Override Component Layer Some footprints may have their components defined on the opposite layer to there actual footprints. In these instances you can override mount side by using this field. Values can be `top`, `bottom`, `t` or `b`. diff --git a/plugins/.DS_Store b/plugins/.DS_Store new file mode 100644 index 0000000..fdae4bd Binary files /dev/null and b/plugins/.DS_Store differ diff --git a/plugins/process.py b/plugins/process.py index e85efd1..6caf8ce 100644 --- a/plugins/process.py +++ b/plugins/process.py @@ -113,25 +113,34 @@ class ProcessManager: netlist_writer = pcbnew.IPC356D_WRITER(self.board) netlist_writer.Write(os.path.join(temp_dir, netlistFileName)) - def _get_footprint_position(self, footprint): - """Calculate position based on center of bounding box.""" - position = footprint.GetPosition() + def _get_footprint_position(self, footprint): attributes = footprint.GetAttributes() - + #determin origin type by packge type if attributes & pcbnew.FP_SMD: + origin_type='Anchor' + else: + origin_type='Center' + + #allow user override + key='Origin' + if footprint_has_field(footprint, key): + origin_type_override = str(footprint_get_field(footprint, key)).capitalize() + if origin_type_override in ['Anchor','Center']: + origin_type=origin_type_override + + if origin_type=='Anchor': position = footprint.GetPosition() - elif attributes & pcbnew.FP_THROUGH_HOLE: - position = footprint.GetBoundingBox(False, False).GetCenter() - else: # handle Unspecified footprint type + else: #if type_origin=='center' or anything ele pads = footprint.Pads() if len(pads) > 0: # get bounding box based on pads only to ignore non-copper layers, e.g. silkscreen bbox = pads[0].GetBoundingBox() # start with small bounding box for pad in pads: bbox.Merge(pad.GetBoundingBox()) # expand bounding box - position = bbox.GetCenter() - + else: + position = footprint.GetPosition() #if we have no pads we fallback to anchor + return position def generate_tables(self, temp_dir, auto_translate, exclude_dnp):