summaryrefslogtreecommitdiff
path: root/gerbonara/rs274x.py
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2022-06-10 00:39:07 +0200
committerjaseg <git@jaseg.de>2022-06-10 00:39:07 +0200
commit460ea625af5c1d9e243feaa49923f7b2c7db8837 (patch)
tree3d7e71e3015d0dd70c7d5f8478448a5cdd369d30 /gerbonara/rs274x.py
parente422243a6e76d0b798ae8f175a717c193be4d22a (diff)
downloadgerbonara-460ea625af5c1d9e243feaa49923f7b2c7db8837.tar.gz
gerbonara-460ea625af5c1d9e243feaa49923f7b2c7db8837.tar.bz2
gerbonara-460ea625af5c1d9e243feaa49923f7b2c7db8837.zip
Fix merging, bounding boxes and svg precision
Diffstat (limited to 'gerbonara/rs274x.py')
-rw-r--r--gerbonara/rs274x.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/gerbonara/rs274x.py b/gerbonara/rs274x.py
index 5bfcc3f..1d18ec3 100644
--- a/gerbonara/rs274x.py
+++ b/gerbonara/rs274x.py
@@ -77,11 +77,12 @@ class GerberFile(CamFile):
def to_gerber(self):
return
- def merge(self, other):
+ def merge(self, other, mode='above', keep_settings=False):
if other is None:
return
- self.import_settings = None
+ if not keep_settings:
+ self.import_settings = None
self.comments += other.comments
# dedup apertures
@@ -96,7 +97,13 @@ class GerberFile(CamFile):
replace_apertures[id(ap)] = new_apertures[gbr]
self.apertures = list(new_apertures.values())
- self.objects += other.objects
+ # Join objects
+ if mode == 'below':
+ self.objects = other.objects + self.objects
+ elif mode == 'above':
+ self.objects += other.objects
+ else:
+ raise ValueError(f'Invalid mode "{mode}", must be one of "above" or "below".')
for obj in self.objects:
# If object has an aperture attribute, replace that aperture.
if (ap := replace_apertures.get(id(getattr(obj, 'aperture', None)))):