From a7bf1b080cc2a75f00b2318a6609f42030a82e4f Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Sun, 25 Apr 2021 12:20:39 -0300 Subject: [PATCH] Added skip_top and skip_bottom options to the rot_footprint filter. --- CHANGELOG.md | 6 ++++++ README.md | 2 ++ kibot/fil_rot_footprint.py | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index aaebc230..226a69ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] +### Added +- Options to better control the rotation filter (#60 and #67): + - invert_bottom: bottom angles are inverted. + - skip_top: top components aren't rotated. + - skip_bottom: bottom components aren't rotated. ## [0.11.0] - 2021-04-25 ### Added diff --git a/README.md b/README.md index ef73b45e..e3ee358f 100644 --- a/README.md +++ b/README.md @@ -348,6 +348,8 @@ Currently the only type available is `generic`. - `negative_bottom`: [boolean=true] Rotation for bottom components is computed via subtraction as `(component rot - angle)`. - `rotations`: [list(list(string))] A list of pairs regular expression/rotation. Components matching the regular expression will be rotated the indicated angle. + - `skip_bottom`: [boolean=false] Do not rotate components on the bottom. + - `skip_top`: [boolean=false] Do not rotate components on the top. - subparts: Subparts This filter implements the KiCost subparts mechanism. * Valid keys: diff --git a/kibot/fil_rot_footprint.py b/kibot/fil_rot_footprint.py index d3be6b0a..09f0e79b 100644 --- a/kibot/fil_rot_footprint.py +++ b/kibot/fil_rot_footprint.py @@ -68,6 +68,10 @@ class Rot_Footprint(BaseFilter): # noqa: F821 self.rotations = Optionable """ [list(list(string))] A list of pairs regular expression/rotation. Components matching the regular expression will be rotated the indicated angle """ + self.skip_bottom = False + """ Do not rotate components on the bottom """ + self.skip_top = False + """ Do not rotate components on the top """ def config(self, parent): super().config(parent) @@ -92,6 +96,9 @@ class Rot_Footprint(BaseFilter): # noqa: F821 def filter(self, comp): """ Apply the rotation """ + if (self.skip_top and not comp.bottom) or (self.skip_bottom and comp.bottom): + # Component should be excluded + return for regex, angle in self._rot: if regex.search(comp.footprint): old_angle = comp.footprint_rot