From 07e221652ebd9c09932b080ff1c925222f4498c8 Mon Sep 17 00:00:00 2001 From: Mario Voigt Date: Wed, 12 Aug 2020 22:47:42 +0200 Subject: [PATCH] no message --- extensions/fablabchemnitz_cleangroups.inx | 14 ++++++++++++++ extensions/fablabchemnitz_cleangroups.py | 16 ++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 extensions/fablabchemnitz_cleangroups.inx create mode 100644 extensions/fablabchemnitz_cleangroups.py diff --git a/extensions/fablabchemnitz_cleangroups.inx b/extensions/fablabchemnitz_cleangroups.inx new file mode 100644 index 00000000..e359e8b8 --- /dev/null +++ b/extensions/fablabchemnitz_cleangroups.inx @@ -0,0 +1,14 @@ + + + Remove Empty Groups + fablabchemnitz.de.cleangroups + + path + + + + + + \ No newline at end of file diff --git a/extensions/fablabchemnitz_cleangroups.py b/extensions/fablabchemnitz_cleangroups.py new file mode 100644 index 00000000..4257f162 --- /dev/null +++ b/extensions/fablabchemnitz_cleangroups.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python3 + +import inkex + +class CleanGroups(inkex.Effect): + + def __init__(self): + inkex.Effect.__init__(self) + + def effect(self): + groups = self.document.xpath('//svg:g',namespaces=inkex.NSS) + for group in groups: + if len(group.getchildren()) == 0: + group.getparent().remove(group) + +CleanGroups().run() \ No newline at end of file