#!/usr/bin/env pythonfrom__future__importprint_functionimportsys# These two lines are only needed if you don't put the script directly into# the installation directoryimportsyssys.path.append('/usr/share/inkscape/extensions')# We will use the inkex module with the predefined Effect base class.importinkex# The simplestyle module provides functions for style parsing.fromsimplestyleimport*classAddSizeEffect(inkex.Effect):def__init__(self):# Call the base class constructor.inkex.Effect.__init__(self)# Define string option "--what" with "-w" shortcut and default value "World".self.OptionParser.add_option('-H','--height',action='store',type='float',dest='height',default=0,help='Increase height by')self.OptionParser.add_option('-w','--width',action='store',type='float',dest='width',default=0,help='Increase width by')self.OptionParser.add_option('-u','--unit',action='store',type='str',dest='unit',default='1.',help='Base unit')defeffect(self):svg=self.document.getroot()unit=self.options.unitif'/'inunit:num,den=(float(v)forvinunit.split('/'))unit=num/denelse:unit=float(unit)dw=self.options.width/unitdh=self.options.height/unitfori,oinself.selected.iteritems():o.attrib['width']=str(float(o.get('width'))+dw)o.attrib['height']=str(float(o.get('height'))+dh)# Create effect instance and apply it.effect=AddSizeEffect()effect.affect()
<?xml version="1.0" encoding="UTF-8"?><inkscape-extensionxmlns="http://www.inkscape.org/namespace/inkscape/extension"><_name>Add size</_name><id>org.ekips.filter.add_size</id><dependencytype="executable"location="extensions">add_size.py</dependency><dependencytype="executable"location="extensions">inkex.py</dependency><paramname="height"type="float"min="-9999.00"max="9999.00"_gui-text="Add to height">0</param><paramname="width"type="float"min="-9999.00"max="9999.00"_gui-text="Add to width">0</param><paramname="unit"type="enum"_gui-text="Base unit"><_itemvalue="72./90">pt</_item><_itemvalue="1./15">pc</_item><_itemvalue="1.">px</_item><_itemvalue="25.4/90">mm</_item><_itemvalue="2.54/90">cm</_item><_itemvalue=".0254/90">m</_item><_itemvalue="1./90">in</_item><_itemvalue="1./1080">ft</_item></param><effect><object-type>all</object-type><effects-menu><submenu_name="My"/></effects-menu></effect><script><commandreldir="extensions"interpreter="python">add_size.py</command></script></inkscape-extension>
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.