diff options
author | jaseg <git@jaseg.de> | 2023-02-19 23:42:17 +0100 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2023-02-19 23:42:17 +0100 |
commit | a374483998baff2fab4c43027c83f8bf97e5fdf5 (patch) | |
tree | 090289b0aa8ea1fe7e425a9d39281cc24e44eae9 /gerbonara/rs274x.py | |
parent | f64b03efc752b682b1cbe8cfb114f19e3362ef76 (diff) | |
download | gerbonara-a374483998baff2fab4c43027c83f8bf97e5fdf5.tar.gz gerbonara-a374483998baff2fab4c43027c83f8bf97e5fdf5.tar.bz2 gerbonara-a374483998baff2fab4c43027c83f8bf97e5fdf5.zip |
cli: First draft of most of the CLI
Diffstat (limited to 'gerbonara/rs274x.py')
-rw-r--r-- | gerbonara/rs274x.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/gerbonara/rs274x.py b/gerbonara/rs274x.py index b480b86..f770c51 100644 --- a/gerbonara/rs274x.py +++ b/gerbonara/rs274x.py @@ -67,7 +67,7 @@ class GerberFile(CamFile): not isinstance(obj.aperture, apertures.CircleAperture): raise ValueError(f'Cannot convert {obj} to excellon!') - if not (new_tool := new_tools.get(id(obj.aperture))): + if not (new_tool := new_tools.get(obj.aperture)): # TODO plating? new_tool = new_tools[id(obj.aperture)] = apertures.ExcellonTool(obj.aperture.diameter, plated=plated, unit=obj.aperture.unit) new_objs.append(dataclasses.replace(obj, aperture=new_tool)) @@ -271,16 +271,19 @@ class GerberFile(CamFile): def __len__(self): return len(self.objects) - def scale(self, scale, unit=MM): + def scale(self, factor, unit=MM): scaled_apertures = {} + for ap in self.apertures: + scaled_apertures[id(ap)] = ap.scaled(factor) + for obj in self.objects: - obj.scale(sx, sy) + obj.scale(factor) + + if (obj_ap := getattr(obj, 'aperture', None)): + obj.aperture = scaled_apertures[id(obj_ap)] - if (aperture := getattr(obj, 'aperture', None)): - if not (scaled := scaled_apertures.get(aperture)): - scaled = scaled_apertures[aperture] = aperture.scaled(scale) - obj.aperture = scaled + self.apertures = list(scaled_apertures.values()) def offset(self, dx=0, dy=0, unit=MM): # TODO round offset to file resolution |