From ad30484ecbe4bfe437afd7e0aeab5a8579a8adec Mon Sep 17 00:00:00 2001 From: scottvr Date: Fri, 8 Jan 2021 23:31:50 -0600 Subject: [PATCH 1/5] Update to work with Python 3 and Inkscape 1.0 --- inkscape_contributed/eggbot_pptb.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/inkscape_contributed/eggbot_pptb.py b/inkscape_contributed/eggbot_pptb.py index 320bab8d..f4b8ec2d 100755 --- a/inkscape_contributed/eggbot_pptb.py +++ b/inkscape_contributed/eggbot_pptb.py @@ -25,28 +25,31 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# 8 January 2021 +# Python 3 and Inkscape 1.0 update by Scott VanRavenswaay ( scottvr at gmail dot com ) import gettext import inkex import simplestyle - +from lxml import etree class EggBot_PostProcessTraceBitmap(inkex.Effect): def __init__(self): inkex.Effect.__init__(self) - self.OptionParser.add_option( + self.arg_parser.add_argument( "--outlineRegions", action="store", dest="outlineRegions", - type="inkbool", default=True, + type=inkex.Boolean, default=True, help="Outline the regions with a stroked line of the same color as the region itself") - self.OptionParser.add_option( + self.arg_parser.add_argument( "--fillRegions", action="store", dest="fillRegions", - type="inkbool", default=True, + type=inkex.Boolean, default=True, help="Fill regions with color") - self.OptionParser.add_option( + self.arg_parser.add_argument( "--removeImage", action="store", dest="removeImage", - type="inkbool", default=True, + type=inkex.Boolean, default=True, help="Remove the traced bitmap image from the drawing") def effect(self): @@ -60,7 +63,8 @@ def effect(self): stroke, fill, color = ('none', 'none', 'unknown') # Get the paths style attribute - style = simplestyle.parseStyle(path.get('style', '')) + style = dict(inkex.Style.parse_str(path.get('style', ''))) + # Obtain the fill color from the path's style attribute if 'fill' in style: color = style['fill'] @@ -76,10 +80,10 @@ def effect(self): style['stroke'] = stroke # And change the style attribute for the path - path.set('style', simplestyle.formatStyle(style)) + path.set('style', inkex.Style.to_str(style)) # Create a group element under the document root - layer = inkex.etree.SubElement(root, inkex.addNS('g', 'svg')) + layer = etree.SubElement(root, inkex.addNS('g', 'svg')) # Add Inkscape layer attributes to this new group count += 1 @@ -113,4 +117,4 @@ def effect(self): if __name__ == '__main__': e = EggBot_PostProcessTraceBitmap() - e.affect() + e.run() From 293877ccd77bbcad06239594954f860e34a2173b Mon Sep 17 00:00:00 2001 From: scottvr Date: Fri, 8 Jan 2021 23:40:24 -0600 Subject: [PATCH 2/5] Revert "Update to work with Python 3 and Inkscape 1.0" This reverts commit ad30484ecbe4bfe437afd7e0aeab5a8579a8adec. --- inkscape_contributed/eggbot_pptb.py | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/inkscape_contributed/eggbot_pptb.py b/inkscape_contributed/eggbot_pptb.py index f4b8ec2d..320bab8d 100755 --- a/inkscape_contributed/eggbot_pptb.py +++ b/inkscape_contributed/eggbot_pptb.py @@ -25,31 +25,28 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# 8 January 2021 -# Python 3 and Inkscape 1.0 update by Scott VanRavenswaay ( scottvr at gmail dot com ) import gettext import inkex import simplestyle -from lxml import etree + class EggBot_PostProcessTraceBitmap(inkex.Effect): def __init__(self): inkex.Effect.__init__(self) - self.arg_parser.add_argument( + self.OptionParser.add_option( "--outlineRegions", action="store", dest="outlineRegions", - type=inkex.Boolean, default=True, + type="inkbool", default=True, help="Outline the regions with a stroked line of the same color as the region itself") - self.arg_parser.add_argument( + self.OptionParser.add_option( "--fillRegions", action="store", dest="fillRegions", - type=inkex.Boolean, default=True, + type="inkbool", default=True, help="Fill regions with color") - self.arg_parser.add_argument( + self.OptionParser.add_option( "--removeImage", action="store", dest="removeImage", - type=inkex.Boolean, default=True, + type="inkbool", default=True, help="Remove the traced bitmap image from the drawing") def effect(self): @@ -63,8 +60,7 @@ def effect(self): stroke, fill, color = ('none', 'none', 'unknown') # Get the paths style attribute - style = dict(inkex.Style.parse_str(path.get('style', ''))) - + style = simplestyle.parseStyle(path.get('style', '')) # Obtain the fill color from the path's style attribute if 'fill' in style: color = style['fill'] @@ -80,10 +76,10 @@ def effect(self): style['stroke'] = stroke # And change the style attribute for the path - path.set('style', inkex.Style.to_str(style)) + path.set('style', simplestyle.formatStyle(style)) # Create a group element under the document root - layer = etree.SubElement(root, inkex.addNS('g', 'svg')) + layer = inkex.etree.SubElement(root, inkex.addNS('g', 'svg')) # Add Inkscape layer attributes to this new group count += 1 @@ -117,4 +113,4 @@ def effect(self): if __name__ == '__main__': e = EggBot_PostProcessTraceBitmap() - e.run() + e.affect() From c25be61a482f170b71cb90811784a06eeb139849 Mon Sep 17 00:00:00 2001 From: scottvr Date: Fri, 8 Jan 2021 23:42:29 -0600 Subject: [PATCH 3/5] Update for Inkscape 1.0 --- inkscape_contributed/eggbot_pptb.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/inkscape_contributed/eggbot_pptb.py b/inkscape_contributed/eggbot_pptb.py index 320bab8d..8f18aa55 100755 --- a/inkscape_contributed/eggbot_pptb.py +++ b/inkscape_contributed/eggbot_pptb.py @@ -25,28 +25,31 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# 8 January 2021 +# Inkscape 1.0 update by Scott VanRavenswaay ( scottvr at gmail dot com ) import gettext import inkex import simplestyle - +from lxml import etree class EggBot_PostProcessTraceBitmap(inkex.Effect): def __init__(self): inkex.Effect.__init__(self) - self.OptionParser.add_option( + self.arg_parser.add_argument( "--outlineRegions", action="store", dest="outlineRegions", - type="inkbool", default=True, + type=inkex.Boolean, default=True, help="Outline the regions with a stroked line of the same color as the region itself") - self.OptionParser.add_option( + self.arg_parser.add_argument( "--fillRegions", action="store", dest="fillRegions", - type="inkbool", default=True, + type=inkex.Boolean, default=True, help="Fill regions with color") - self.OptionParser.add_option( + self.arg_parser.add_argument( "--removeImage", action="store", dest="removeImage", - type="inkbool", default=True, + type=inkex.Boolean, default=True, help="Remove the traced bitmap image from the drawing") def effect(self): @@ -60,7 +63,8 @@ def effect(self): stroke, fill, color = ('none', 'none', 'unknown') # Get the paths style attribute - style = simplestyle.parseStyle(path.get('style', '')) + style = dict(inkex.Style.parse_str(path.get('style', ''))) + # Obtain the fill color from the path's style attribute if 'fill' in style: color = style['fill'] @@ -76,10 +80,10 @@ def effect(self): style['stroke'] = stroke # And change the style attribute for the path - path.set('style', simplestyle.formatStyle(style)) + path.set('style', inkex.Style.to_str(style)) # Create a group element under the document root - layer = inkex.etree.SubElement(root, inkex.addNS('g', 'svg')) + layer = etree.SubElement(root, inkex.addNS('g', 'svg')) # Add Inkscape layer attributes to this new group count += 1 @@ -113,4 +117,4 @@ def effect(self): if __name__ == '__main__': e = EggBot_PostProcessTraceBitmap() - e.affect() + e.run() From 623a5f6c72ac343fe5b2a336f574d30fa05c21f0 Mon Sep 17 00:00:00 2001 From: scottvr Date: Fri, 8 Jan 2021 23:45:04 -0600 Subject: [PATCH 4/5] remove deprecated simplestyle import --- inkscape_contributed/eggbot_pptb.py | 1 - 1 file changed, 1 deletion(-) diff --git a/inkscape_contributed/eggbot_pptb.py b/inkscape_contributed/eggbot_pptb.py index 8f18aa55..d8e491e3 100755 --- a/inkscape_contributed/eggbot_pptb.py +++ b/inkscape_contributed/eggbot_pptb.py @@ -32,7 +32,6 @@ import gettext import inkex -import simplestyle from lxml import etree class EggBot_PostProcessTraceBitmap(inkex.Effect): From 0a157a1c89d6f7172fcfe69de12498105da3338f Mon Sep 17 00:00:00 2001 From: scottvr Date: Fri, 8 Jan 2021 23:45:04 -0600 Subject: [PATCH 5/5] change errormsg to utils.debugremove deprecated simplestyle import --- inkscape_contributed/eggbot_pptb.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/inkscape_contributed/eggbot_pptb.py b/inkscape_contributed/eggbot_pptb.py index 8f18aa55..92878485 100755 --- a/inkscape_contributed/eggbot_pptb.py +++ b/inkscape_contributed/eggbot_pptb.py @@ -32,7 +32,6 @@ import gettext import inkex -import simplestyle from lxml import etree class EggBot_PostProcessTraceBitmap(inkex.Effect): @@ -112,7 +111,7 @@ def effect(self): except: parent.remove(node) - inkex.errormsg(gettext.gettext('Finished. Created %d layers') % count) + inkex.utils.debug(gettext.gettext('Finished. Created %d layers') % count) if __name__ == '__main__':