Updated some extension structures to more modern argument parser method

This commit is contained in:
Mario Voigt 2021-04-15 17:03:47 +02:00
parent 280cc8b878
commit f14ffb9952
84 changed files with 713 additions and 769 deletions

View File

@ -433,16 +433,15 @@ class LineGeneratorForHorizontalCards(LineGeneratorBase):
return lines return lines
class FoldedCardLayoutGuidesEffect(inkex.EffectExtension): class FoldedCardLayoutGuidesEffect(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self)
self.arg_parser.add_argument('-l', '--layout') def add_arguments(self, pars):
self.arg_parser.add_argument('-w', '--card_width', type = float) pars.add_argument('-l', '--layout')
self.arg_parser.add_argument('-d', '--card_height', type = float) pars.add_argument('-w', '--card_width', type = float)
self.arg_parser.add_argument('-o', '--orientation') pars.add_argument('-d', '--card_height', type = float)
self.arg_parser.add_argument('-c', '--card_margin', type = float) pars.add_argument('-o', '--orientation')
self.arg_parser.add_argument('-b', '--bleed_margin', type = float) pars.add_argument('-c', '--card_margin', type = float)
self.arg_parser.add_argument('-p', '--page_margin', type = float) pars.add_argument('-b', '--bleed_margin', type = float)
pars.add_argument('-p', '--page_margin', type = float)
def effect(self): def effect(self):
# find dimensions of page # find dimensions of page

View File

@ -24,11 +24,11 @@ import inkex
inkex.NSS[u'cs'] = u'http://www.razorfoss.org/tuckboxextension/' inkex.NSS[u'cs'] = u'http://www.razorfoss.org/tuckboxextension/'
class InsertPaperTemplateEffect(inkex.Effect): class InsertPaperTemplateEffect(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self) def add_arguments(self, pars):
self.arg_parser.add_argument('-p', '--papertype') pars.add_argument('-p', '--papertype')
self.arg_parser.add_argument('-s', '--show_type') pars.add_argument('-s', '--show_type')
### colour ### ### colour ###
self.StrokeWidthMM = 0.25 self.StrokeWidthMM = 0.25

View File

@ -26,14 +26,14 @@ def BoundingBoxArea(node):
bb = node.bounding_box() bb = node.bounding_box()
return bb.width * bb.height return bb.width * bb.height
class InsetAlignmentCreateEffect(inkex.Effect): class InsetAlignmentCreateEffect(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self) def add_arguments(self, pars):
self.arg_parser.add_argument('-a', '--anchor_node') pars.add_argument('-a', '--anchor_node')
self.arg_parser.add_argument('-v', '--relative_to_v') pars.add_argument('-v', '--relative_to_v')
self.arg_parser.add_argument('-t', '--relative_to_h') pars.add_argument('-t', '--relative_to_h')
self.arg_parser.add_argument('-x', '--inset_x', type = float) pars.add_argument('-x', '--inset_x', type = float)
self.arg_parser.add_argument('-y', '--inset_y', type = float) pars.add_argument('-y', '--inset_y', type = float)
def GetPaths(self): def GetPaths(self):
paths = [] paths = []

View File

@ -105,9 +105,7 @@ class GuideDefiniton():
#return "{} - p1:({}, {}) p2:({}, {}) - {}, {}, {}".format(self.id, self.p1.x, self.p1.y, self.p2.x, self.p2.y, self.slope, self.xIntercept, self.yIntercept) #return "{} - p1:({}, {}) p2:({}, {}) - {}, {}, {}".format(self.id, self.p1.x, self.p1.y, self.p2.x, self.p2.y, self.slope, self.xIntercept, self.yIntercept)
return "{} - {}".format(self.id, self.interceptSerial()) return "{} - {}".format(self.id, self.interceptSerial())
class RemoveDuplicateGuidesEffect(inkex.Effect): class RemoveDuplicateGuidesEffect(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self)
def effect(self): def effect(self):
# enumerate all guides # enumerate all guides

View File

@ -42,14 +42,13 @@ def pts2curve(cplxs):
class AffineSpirals(inkex.EffectExtension): class AffineSpirals(inkex.EffectExtension):
def __init__(self): def add_arguments(self, pars):
inkex.Effect.__init__(self) pars.add_argument("--num_lines", type=int, default=3)
self.arg_parser.add_argument("--num_lines", type=int, default=3) pars.add_argument("--num_petals", type=int, default=3)
self.arg_parser.add_argument("--num_petals", type=int, default=3) pars.add_argument("--shrink_ratio", type=float, default=3)
self.arg_parser.add_argument("--shrink_ratio", type=float, default=3) #pars.add_argument("--mk_filled", type=inkex.Boolean, default=False)
#self.arg_parser.add_argument("--mk_filled", type=inkex.Boolean, default=False) pars.add_argument("--mk_full", type=inkex.Boolean, default=False)
self.arg_parser.add_argument("--mk_full", type=inkex.Boolean, default=False) pars.add_argument("--active-tab", default='title')
self.arg_parser.add_argument("--active-tab", default='title')
def calc_unit_factor(self): def calc_unit_factor(self):
unit_factor = self.svg.unittouu(str(1.0) + self.options.units) unit_factor = self.svg.unittouu(str(1.0) + self.options.units)

View File

@ -241,19 +241,18 @@ def complex2tulpe(complexNb):
''' '''
class AnotherPerspective(inkex.EffectExtension): class AnotherPerspective(inkex.EffectExtension):
def __init__(self): def envelope2coords(self, path_envelope):
inkex.Effect.__init__(self)
def envelope2coords(self,path_envelope):
pp_envelope = CubicSuperPath(path_envelope) pp_envelope = CubicSuperPath(path_envelope)
# inkex.debug(pp_envelope) if len(pp_envelope[0]) < 4:
inkex.errormsg("The selected envelope (your second path) does not contain enough nodes. Check to have at least 4 nodes.")
exit()
c0 = pp_envelope[0][0][0] c0 = pp_envelope[0][0][0]
c1 = pp_envelope[0][1][0] c1 = pp_envelope[0][1][0]
c2 = pp_envelope[0][2][0] c2 = pp_envelope[0][2][0]
c3 = pp_envelope[0][3][0] c3 = pp_envelope[0][3][0]
# inkex.debug(str(c0)+" "+str(c1)+" "+str(c2)+" "+str(c3)) # inkex.debug(str(c0)+" "+str(c1)+" "+str(c2)+" "+str(c3))
return [c0,c1,c2,c3] return [c0, c1, c2, c3]
def effect(self): def effect(self):
if len(self.options.ids) < 2: if len(self.options.ids) < 2:

View File

@ -18,14 +18,14 @@ from lxml import etree
from math import cos, sin, pi, log, sqrt from math import cos, sin, pi, log, sqrt
class Archimedes(inkex.EffectExtension): class Archimedes(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self) def add_arguments(self, pars):
self.arg_parser.add_argument('--r', type = int, default = '50') pars.add_argument('--r', type = int, default = '50')
self.arg_parser.add_argument('--a', type = float, default = '3') pars.add_argument('--a', type = float, default = '3')
self.arg_parser.add_argument('--step', type = int, default = '50') pars.add_argument('--step', type = int, default = '50')
self.arg_parser.add_argument('--trl', default = '1') pars.add_argument('--trl', default = '1')
self.arg_parser.add_argument('--turns', type = float, default = '5') pars.add_argument('--turns', type = float, default = '5')
self.arg_parser.add_argument('--length', type = float, default = '500') pars.add_argument('--length', type = float, default = '500')
def effect(self): def effect(self):
th = pi / 3 th = pi / 3

View File

@ -4,24 +4,26 @@ import inkex
import sys import sys
class AttribEditor(inkex.EffectExtension): class AttribEditor(inkex.EffectExtension):
def __init__(self): def add_arguments(self, pars):
inkex.Effect.__init__(self) pars.add_argument("-a", "--attributeName", help="attribute name to set")
self.arg_parser.add_argument("-a", "--attributeName", help="attribute name to set") pars.add_argument("-v", "--attributeValue", help="attribute value to set")
self.arg_parser.add_argument("-v", "--attributeValue", help="attribute value to set") pars.add_argument("-m", "--mode", default="set", help="mode of operation")
self.arg_parser.add_argument("-m", "--mode", default="set", help="mode of operation")
def effect(self): def effect(self):
if not self.options.attributeName: # if attributeName is not given if not self.options.attributeName: # if attributeName is not given
self.OptionParser.error("Attribute name not given") inkex.errormsg("Attribute name not given")
return
if not self.options.attributeValue: # required to make proper behaviour
inkex.errormsg("Please define proper attribute value")
return
elements = self.svg.selected.values() elements = self.svg.selected.values()
for el in elements: for el in elements:
currentAtt = el.attrib.get(self.options.attributeName) currentAtt = el.attrib.get(self.options.attributeName)
if currentAtt is None: if currentAtt is None:
currentAtt = "" currentAtt = ""
if self.options.mode == "set": if self.options.mode == "set":
el.attrib[self.options.attributeName] = self.options.attributeValue el.set(self.options.attributeName, self.options.attributeValue)
elif self.options.mode == "append": elif self.options.mode == "append":
el.attrib[self.options.attributeName] = currentAtt + self.options.attributeValue el.attrib[self.options.attributeName] = currentAtt + self.options.attributeValue
elif self.options.mode == "prefix": elif self.options.mode == "prefix":

View File

@ -3,9 +3,8 @@
import inkex import inkex
class AttribImport(inkex.EffectExtension): class AttribImport(inkex.EffectExtension):
def __init__(self): def add_arguments(self, pars):
inkex.Effect.__init__(self) pars.add_argument("--data", default="", help="data file")
self.arg_parser.add_argument("--data", default="", help="data file")
def effect(self): def effect(self):
with open(self.options.data, 'r') as f: with open(self.options.data, 'r') as f:

View File

@ -73,34 +73,34 @@ class BezierEnvelope(inkex.EffectExtension):
segmentTypes = ["move","line","quad","cubic","close"] segmentTypes = ["move","line","quad","cubic","close"]
def __init__(self):
inkex.Effect.__init__(self)
def effect(self): def effect(self):
if len(self.options.ids) < 2: if len(self.options.ids) < 2:
raise Exception("Two paths must be selected. The 1st is the letter, the 2nd is the envelope and must have 4 sides.") inkex.errormsg("Two paths must be selected. The 1st is the letter, the 2nd is the envelope and must have 4 sides.")
exit() exit()
letterElement = self.svg.selected[self.options.ids[0]] letterElement = self.svg.selected[self.options.ids[0]]
envelopeElement = self.svg.selected[self.options.ids[1]] envelopeElement = self.svg.selected[self.options.ids[1]]
if letterElement.get('inkscape:original-d') or envelopeElement.get('inkscape:original-d'): if letterElement.get('inkscape:original-d') or envelopeElement.get('inkscape:original-d'):
raise Exception("One or both selected paths have attribute 'inkscape:original-d' which points to Live Path Effects (LPE). Please convert to regular path.") inkex.errormsg("One or both selected paths have attribute 'inkscape:original-d' which points to Live Path Effects (LPE). Please convert to regular path.")
exit() exit()
if letterElement.tag != inkex.addNS('path','svg') or envelopeElement.tag != inkex.addNS('path','svg'): if letterElement.tag != inkex.addNS('path','svg') or envelopeElement.tag != inkex.addNS('path','svg'):
raise Exception("Both letter and envelope must be SVG paths.") inkex.errormsg("Both letter and envelope must be SVG paths.")
exit() exit()
axes = extractMorphAxes( Path( envelopeElement.get('d') ).to_arrays() ) axes = extractMorphAxes(Path( envelopeElement.get('d') ).to_arrays())
if axes is None: if axes is None:
raise Exception("No axes found on envelope.") inkex.errormsg("No axes found on envelope.")
exit()
axisCount = len(axes) axisCount = len(axes)
if axisCount < 4: if axisCount < 4:
raise Exception("The envelope path has less than 4 segments.") inkex.errormsg("The envelope path has less than 4 segments.")
exit()
for i in range( 0, 4 ): for i in range( 0, 4 ):
if axes[i] is None: if axes[i] is None:
raise Exception("axes[%i] is None" % i) inkex.errormsg("axis[%i] is None" % i)
exit()
# morph the enveloped element according to the axes # morph the enveloped element according to the axes
morph_element( letterElement, envelopeElement, axes ); morph_element( letterElement, envelopeElement, axes );
@ -112,7 +112,7 @@ def morph_element( letterElement, envelopeElement, axes ):
# Morphs a path into a new path, according to cubic curved bounding axes. # Morphs a path into a new path, according to cubic curved bounding axes.
def morphPath( path, axes ): def morphPath(path, axes):
bounds = [y for x in list(Path(path).bounding_box()) for y in list(x)] bounds = [y for x in list(Path(path).bounding_box()) for y in list(x)]
assert len(bounds) == 4 assert len(bounds) == 4
new_path = [] new_path = []

View File

@ -15,17 +15,16 @@ The expected degree of the polygon is sqrt(n). The corners
are blunted by the blunt parameter. 0 means sharp. 1 will are blunted by the blunt parameter. 0 means sharp. 1 will
result in loopy splines. result in loopy splines.
""" """
def __init__(self): def add_arguments(self, pars):
inkex.Effect.__init__(self) pars.add_argument("--pgsizep", type=inkex.Boolean, default=True, help="Default rectangle to page size?")
self.arg_parser.add_argument("--pgsizep", type=inkex.Boolean, default=True, help="Default rectangle to page size?") pars.add_argument('--num', type = int, default = 25, help = 'Number of random points to start with')
self.arg_parser.add_argument('--num', type = int, default = 25, help = 'Number of random points to start with') pars.add_argument('--blunt', type = float, default = 0.3, help = 'Bluntness of corners. Should be < 1')
self.arg_parser.add_argument('--blunt', type = float, default = 0.3, help = 'Bluntness of corners. Should be < 1') pars.add_argument('--cave', type = float, default = 0.0, help = 'Concavity. Less blobby and more splatty')
self.arg_parser.add_argument('--cave', type = float, default = 0.0, help = 'Concavity. Less blobby and more splatty') pars.add_argument('--rx', type = int, default = 1000, help = 'Size of work area x')
self.arg_parser.add_argument('--rx', type = int, default = 1000, help = 'Size of work area x') pars.add_argument('--ry', type = int, default = 1000, help = 'Size of work area y')
self.arg_parser.add_argument('--ry', type = int, default = 1000, help = 'Size of work area y') pars.add_argument('--sz', type = float, default = 50., help = 'Size of a blob')
self.arg_parser.add_argument('--sz', type = float, default = 50., help = 'Size of a blob') pars.add_argument('--nb', type = int, default = 10, help = 'Total number of blobs')
self.arg_parser.add_argument('--nb', type = int, default = 10, help = 'Total number of blobs') pars.add_argument("--Nmain", default='top', help="Active tab.")
self.arg_parser.add_argument("--Nmain", default='top', help="Active tab.")
def effect(self): def effect(self):
global cave global cave

View File

@ -5,12 +5,12 @@ import math
from lxml import etree from lxml import etree
class DrawBBoxes(inkex.EffectExtension): class DrawBBoxes(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self) def add_arguments(self, pars):
self.arg_parser.add_argument('--offset', type=float, default=0.0, help='Offset from object (all directions)') pars.add_argument('--offset', type=float, default=0.0, help='Offset from object (all directions)')
self.arg_parser.add_argument('--box', type=inkex.Boolean, default=0.0, help='Draw boxes') pars.add_argument('--box', type=inkex.Boolean, default=0.0, help='Draw boxes')
self.arg_parser.add_argument('--circle', type=inkex.Boolean, default=0.0, help='Draw circles') pars.add_argument('--circle', type=inkex.Boolean, default=0.0, help='Draw circles')
self.arg_parser.add_argument('--split', type = inkex.Boolean, default = True, help = 'Handle selection as group') pars.add_argument('--split', type = inkex.Boolean, default = True, help = 'Handle selection as group')
def drawBBox(self, bbox): def drawBBox(self, bbox):
if self.options.box: if self.options.box:

View File

@ -44,12 +44,11 @@ class BouwkampCodeExtension(inkex.EffectExtension):
Bouwkamp codes and table codes. Bouwkamp codes and table codes.
""" """
def __init__(self): def add_arguments(self, pars):
inkex.Effect.__init__(self) pars.add_argument('--tab')
self.arg_parser.add_argument('--tab') pars.add_argument('--bouwkamp_code', default='21, 112, 112, [50, 35, 27], [8, 19], [15, 17, 11], [6, 24], [29, 25, 9, 2], [7, 18], [16], [42], [4, 37], [33]', help='The Bouwkamp code.'
self.arg_parser.add_argument('--bouwkamp_code', default='21, 112, 112, [50, 35, 27], [8, 19], [15, 17, 11], [6, 24], [29, 25, 9, 2], [7, 18], [16], [42], [4, 37], [33]', help='The Bouwkamp code.'
) )
self.arg_parser.add_argument('--wrap_in_group', type=inkex.Boolean, default=True, help='Should the generated items be wrapped inside a group.' pars.add_argument('--wrap_in_group', type=inkex.Boolean, default=True, help='Should the generated items be wrapped inside a group.'
) )
def effect(self): def effect(self):

View File

@ -35,15 +35,15 @@ def punkte_erstellen(punkte, x, y):
punkte.append((x, y)) punkte.append((x, y))
class Dose(inkex.EffectExtension): class Dose(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self) def add_arguments(self, pars):
self.arg_parser.add_argument("--height", type=int, default = 50, help="Höhe der Dose") pars.add_argument("--height", type=int, default = 50, help="Höhe der Dose")
self.arg_parser.add_argument("--overhang", type=int, default = 40, help="Überstand des Deckels") pars.add_argument("--overhang", type=int, default = 40, help="Überstand des Deckels")
self.arg_parser.add_argument("--diameter", type=int, default = 40, help="diameter der Dose") pars.add_argument("--diameter", type=int, default = 40, help="diameter der Dose")
self.arg_parser.add_argument("--angle", type=float, default = 22.5, help="angle der segments") pars.add_argument("--angle", type=float, default = 22.5, help="angle der segments")
self.arg_parser.add_argument("--material", type=float, default = 3.6, help="Materialstärke") pars.add_argument("--material", type=float, default = 3.6, help="Materialstärke")
self.arg_parser.add_argument("--bottom", type=inkex.Boolean, default = False, help="Deckel und bottom?") pars.add_argument("--bottom", type=inkex.Boolean, default = False, help="Deckel und bottom?")
self.arg_parser.add_argument("--active-tab", default='title', help="Active tab.") pars.add_argument("--active-tab", default='title', help="Active tab.")
self.deckel_punkte = [] self.deckel_punkte = []
self.deckel_pfad = [] self.deckel_pfad = []

View File

@ -62,15 +62,15 @@ def draw_grid(x, y, rows, cols, size, color1, color2, parent):
draw_square(x + col * size, y + row * size, size, size, color, group, id_) draw_square(x + col * size, y + row * size, size, size, color, group, id_)
class Checkerboard(inkex.EffectExtension): class Checkerboard(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self) def add_arguments(self, pars):
self.arg_parser.add_argument("--tab") pars.add_argument("--tab")
self.arg_parser.add_argument("--color1", type=Color, default=4286282751) pars.add_argument("--color1", type=Color, default=4286282751)
self.arg_parser.add_argument("--color2", type=Color, default=8092671) pars.add_argument("--color2", type=Color, default=8092671)
self.arg_parser.add_argument("--size") pars.add_argument("--size")
self.arg_parser.add_argument("--rows", type=int) pars.add_argument("--rows", type=int)
self.arg_parser.add_argument("--cols", type=int) pars.add_argument("--cols", type=int)
self.arg_parser.add_argument("--layer", type=inkex.Boolean) pars.add_argument("--layer", type=inkex.Boolean)
def effect(self): def effect(self):
if self.svg.get_current_layer() is not None: if self.svg.get_current_layer() is not None:

View File

@ -82,32 +82,31 @@ Creates visual noise. 3 kinds: Scratches, chips, specks.
randomly and scattered randomly across the page. Controls randomly and scattered randomly across the page. Controls
for number and size, as well as some specific to each type. for number and size, as well as some specific to each type.
""" """
def __init__(self): def add_arguments(self, pars):
inkex.Effect.__init__(self) pars.add_argument("--pgsizep", type=inkex.Boolean, default=True, help="Default rectangle to page size?")
self.arg_parser.add_argument("--pgsizep", type=inkex.Boolean, default=True, help="Default rectangle to page size?") pars.add_argument("--rx", type=int, default=1000, help="Width")
self.arg_parser.add_argument("--rx", type=int, default=1000, help="Width") pars.add_argument("--ry", type=int, default=1000, help="Height")
self.arg_parser.add_argument("--ry", type=int, default=1000, help="Height") pars.add_argument("--mainSize", type= float, default=1.0, help="Size of objects")
self.arg_parser.add_argument("--mainSize", type= float, default=1.0, help="Size of objects") pars.add_argument("--mainNum", type=int, default=200, help="Number of objects")
self.arg_parser.add_argument("--mainNum", type=int, default=200, help="Number of objects") pars.add_argument("--honp", type=inkex.Boolean, help="Enable scratches")
self.arg_parser.add_argument("--honp", type=inkex.Boolean, help="Enable scratches") pars.add_argument("--hsize", type=float, default=2.0, help="Size of scratches")
self.arg_parser.add_argument("--hsize", type=float, default=2.0, help="Size of scratches") pars.add_argument("--hgrow", type=float, default=0.0, help="Grow scratches with distance")
self.arg_parser.add_argument("--hgrow", type=float, default=0.0, help="Grow scratches with distance") pars.add_argument("--hnum", type= float, default=0.2, help="Number of scratches")
self.arg_parser.add_argument("--hnum", type= float, default=0.2, help="Number of scratches") pars.add_argument("--hrad", type=inkex.Boolean, default=False, help="Angle scratches toward center")
self.arg_parser.add_argument("--hrad", type=inkex.Boolean, default=False, help="Angle scratches toward center") pars.add_argument("--hang", type= float, default=90.0, help="Angle from radius")
self.arg_parser.add_argument("--hang", type= float, default=90.0, help="Angle from radius") pars.add_argument("--hcurve", type= float, default=0.0, help="Change angle with distance")
self.arg_parser.add_argument("--hcurve", type= float, default=0.0, help="Change angle with distance") pars.add_argument("--hgrad", type=inkex.Boolean, default=False, help="Use density gradient")
self.arg_parser.add_argument("--hgrad", type=inkex.Boolean, default=False, help="Use density gradient") pars.add_argument("--conp", type=inkex.Boolean, default=True, help="Enable chips")
self.arg_parser.add_argument("--conp", type=inkex.Boolean, default=True, help="Enable chips") pars.add_argument("--csize", type= float, default=1.0, help="Size of chips")
self.arg_parser.add_argument("--csize", type= float, default=1.0, help="Size of chips") pars.add_argument("--cgrow", type= float, default=0.0, help="Grow chips with distance")
self.arg_parser.add_argument("--cgrow", type= float, default=0.0, help="Grow chips with distance") pars.add_argument("--cnum", type= float, default=1.0, help="Number of chips")
self.arg_parser.add_argument("--cnum", type= float, default=1.0, help="Number of chips") pars.add_argument("--cgrad", type=inkex.Boolean, default=False, help="Use density gradient")
self.arg_parser.add_argument("--cgrad", type=inkex.Boolean, default=False, help="Use density gradient") pars.add_argument("--sonp", type=inkex.Boolean, default=True, help="Enable specks")
self.arg_parser.add_argument("--sonp", type=inkex.Boolean, default=True, help="Enable specks") pars.add_argument("--ssize", type= float, default=1.0, help="Size of specks")
self.arg_parser.add_argument("--ssize", type= float, default=1.0, help="Size of specks") pars.add_argument("--sgrow", type= float, default=0.0, help="Grow specks with distance")
self.arg_parser.add_argument("--sgrow", type= float, default=0.0, help="Grow specks with distance") pars.add_argument("--snum", type= float, default=10.0, help="Number of specks")
self.arg_parser.add_argument("--snum", type= float, default=10.0, help="Number of specks") pars.add_argument("--sgrad", type=inkex.Boolean, default=False, help="Use density gradient")
self.arg_parser.add_argument("--sgrad", type=inkex.Boolean, default=False, help="Use density gradient") pars.add_argument("--Nmain", "--Overall")
self.arg_parser.add_argument("--Nmain", "--Overall")
def effect(self): def effect(self):
# Get access to main SVG document element and get its dimensions. # Get access to main SVG document element and get its dimensions.

View File

@ -16,9 +16,6 @@ License: GNU GPL v3
class CleanGroups(inkex.EffectExtension): class CleanGroups(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self)
def effect(self): def effect(self):
while True: while True:
groups = self.document.xpath('//svg:g',namespaces=inkex.NSS) groups = self.document.xpath('//svg:g',namespaces=inkex.NSS)

View File

@ -36,20 +36,20 @@ class Cleanup(inkex.EffectExtension):
groups = [] groups = []
def __init__(self): def add_arguments(self, pars):
inkex.Effect.__init__(self) pars.add_argument("--main_tabs")
self.arg_parser.add_argument("--main_tabs") pars.add_argument("--mode", default="Lines", help="Join paths with lines or polygons")
self.arg_parser.add_argument("--dedicated_style_attributes", default="ignore", help="Handling of dedicated style attributes") pars.add_argument("--dedicated_style_attributes", default="ignore", help="Handling of dedicated style attributes")
self.arg_parser.add_argument("--stroke_width_override", type=inkex.Boolean, default=False, help="Override stroke width") pars.add_argument("--stroke_width_override", type=inkex.Boolean, default=False, help="Override stroke width")
self.arg_parser.add_argument("--stroke_width", type=float, default=0.100, help="Stroke width") pars.add_argument("--stroke_width", type=float, default=0.100, help="Stroke width")
self.arg_parser.add_argument("--stroke_width_units", default="mm", help="Stroke width unit") pars.add_argument("--stroke_width_units", default="mm", help="Stroke width unit")
self.arg_parser.add_argument("--stroke_opacity_override", type=inkex.Boolean, default=False, help="Override stroke opacity") pars.add_argument("--stroke_opacity_override", type=inkex.Boolean, default=False, help="Override stroke opacity")
self.arg_parser.add_argument("--stroke_opacity", type=float, default="100.0", help="Stroke opacity (%)") pars.add_argument("--stroke_opacity", type=float, default="100.0", help="Stroke opacity (%)")
self.arg_parser.add_argument("--reset_stroke_attributes", type=inkex.Boolean, help="Remove stroke style attributes 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linejoin', 'stroke-linecap', 'stroke-miterlimit'") pars.add_argument("--reset_stroke_attributes", type=inkex.Boolean, help="Remove stroke style attributes 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linejoin', 'stroke-linecap', 'stroke-miterlimit'")
self.arg_parser.add_argument("--reset_fill_attributes", type=inkex.Boolean, help="Sets 'fill:none;fill-opacity:1;' to style attribute") pars.add_argument("--reset_fill_attributes", type=inkex.Boolean, help="Sets 'fill:none;fill-opacity:1;' to style attribute")
self.arg_parser.add_argument("--apply_hairlines", type=inkex.Boolean, help="Adds 'vector-effect:non-scaling-stroke;' and '-inkscape-stroke:hairline;' Hint: stroke-width is kept in background. All hairlines still have a valued width.") pars.add_argument("--apply_hairlines", type=inkex.Boolean, help="Adds 'vector-effect:non-scaling-stroke;' and '-inkscape-stroke:hairline;' Hint: stroke-width is kept in background. All hairlines still have a valued width.")
self.arg_parser.add_argument("--apply_black_strokes", type=inkex.Boolean, help="Adds 'stroke:#000000;' to style attribute") pars.add_argument("--apply_black_strokes", type=inkex.Boolean, help="Adds 'stroke:#000000;' to style attribute")
self.arg_parser.add_argument("--remove_group_styles", type=inkex.Boolean, help="Remove styles from groups") pars.add_argument("--remove_group_styles", type=inkex.Boolean, help="Remove styles from groups")
def effect(self): def effect(self):
if len(self.svg.selected) == 0: if len(self.svg.selected) == 0:

View File

@ -5,10 +5,10 @@ import inkex
from lxml import etree from lxml import etree
class clonesPerspectiveEffect(inkex.EffectExtension): class clonesPerspectiveEffect(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self) def add_arguments(self, pars):
self.arg_parser.add_argument('--num', type = int, default = 5, help = 'Drag out center of rotation before calling') pars.add_argument('--num', type = int, default = 5, help = 'Drag out center of rotation before calling')
self.arg_parser.add_argument('--ratio', type = float, default = 0.9, help = 'Ratio of size of nearest neighbor to first. Must be < 1') pars.add_argument('--ratio', type = float, default = 0.9, help = 'Ratio of size of nearest neighbor to first. Must be < 1')
def effect(self): def effect(self):
if len(self.svg.selected) != 1: if len(self.svg.selected) != 1:

View File

@ -29,8 +29,7 @@ import re
from inkex.paths import Path from inkex.paths import Path
class CloseCurves(inkex.EffectExtension): class CloseCurves(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self)
def effect(self): def effect(self):
for id, node in self.svg.selected.items(): for id, node in self.svg.selected.items():
if node.tag == inkex.addNS('path','svg'): if node.tag == inkex.addNS('path','svg'):

View File

@ -33,10 +33,10 @@ import re
from lxml import etree from lxml import etree
class ReplaceColorAlpha(inkex.EffectExtension): class ReplaceColorAlpha(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self) def add_arguments(self, pars):
self.arg_parser.add_argument("--from_color", default="000000", help="Replace color") pars.add_argument("--from_color", default="000000", help="Replace color")
self.arg_parser.add_argument("--to_color", default="000000", help="By color + Alpha") pars.add_argument("--to_color", default="000000", help="By color + Alpha")
def effect(self): def effect(self):
saveout = sys.stdout saveout = sys.stdout

View File

@ -17,9 +17,6 @@ from inkex.paths import Path
class ConvertToPolylines(inkex.EffectExtension): class ConvertToPolylines(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self)
#convert a path (curve) to a polyline and remove dangling/duplicate/useless overlapping handles (points) #convert a path (curve) to a polyline and remove dangling/duplicate/useless overlapping handles (points)
def convertPath(self, node): def convertPath(self, node):
if node.tag == inkex.addNS('path','svg'): if node.tag == inkex.addNS('path','svg'):

View File

@ -41,26 +41,26 @@ from inkex.bezier import csplength
class LinksCreator(inkex.EffectExtension): class LinksCreator(inkex.EffectExtension):
def __init__(self):
super(LinksCreator, self).__init__() def add_arguments(self, pars):
self.arg_parser.add_argument("--main_tabs") pars.add_argument("--main_tabs")
self.arg_parser.add_argument("--path_types", default="closed_paths", help="Apply for closed paths, open paths or both") pars.add_argument("--path_types", default="closed_paths", help="Apply for closed paths, open paths or both")
self.arg_parser.add_argument("--creationunit", default="mm", help="Creation Units") pars.add_argument("--creationunit", default="mm", help="Creation Units")
self.arg_parser.add_argument("--creationtype", default="entered_values", help="Creation") pars.add_argument("--creationtype", default="entered_values", help="Creation")
self.arg_parser.add_argument("--link_count", type=int, default=1, help="Link count") pars.add_argument("--link_count", type=int, default=1, help="Link count")
self.arg_parser.add_argument("--link_multiplicator", type=int, default=1, help="If set, we create a set of multiple gaps of same size next to the main gap") pars.add_argument("--link_multiplicator", type=int, default=1, help="If set, we create a set of multiple gaps of same size next to the main gap")
self.arg_parser.add_argument("--length_link", type=float, default=1.000, help="Link length") pars.add_argument("--length_link", type=float, default=1.000, help="Link length")
self.arg_parser.add_argument("--link_offset", type=float, default=0.000, help="Link offset (+/-)") pars.add_argument("--link_offset", type=float, default=0.000, help="Link offset (+/-)")
self.arg_parser.add_argument("--custom_dasharray_value", default="", help="A list of separated lengths that specify the lengths of alternating dashes and gaps. Input only accepts numbers. It ignores percentages or other characters.") pars.add_argument("--custom_dasharray_value", default="", help="A list of separated lengths that specify the lengths of alternating dashes and gaps. Input only accepts numbers. It ignores percentages or other characters.")
self.arg_parser.add_argument("--custom_dashoffset_value", type=float, default=0.000, help="Link offset (+/-)") pars.add_argument("--custom_dashoffset_value", type=float, default=0.000, help="Link offset (+/-)")
self.arg_parser.add_argument("--length_filter", type=inkex.Boolean, default=False, help="Enable path length filtering") pars.add_argument("--length_filter", type=inkex.Boolean, default=False, help="Enable path length filtering")
self.arg_parser.add_argument("--length_filter_value", type=float, default=0.000, help="Paths with length more than") pars.add_argument("--length_filter_value", type=float, default=0.000, help="Paths with length more than")
self.arg_parser.add_argument("--length_filter_unit", default="mm", help="Length filter unit") pars.add_argument("--length_filter_unit", default="mm", help="Length filter unit")
self.arg_parser.add_argument("--keep_selected", type=inkex.Boolean, default=False, help="Keep selected elements") pars.add_argument("--keep_selected", type=inkex.Boolean, default=False, help="Keep selected elements")
self.arg_parser.add_argument("--no_convert", type=inkex.Boolean, default=False, help="Do not create segments (cosmetic gaps only)") pars.add_argument("--no_convert", type=inkex.Boolean, default=False, help="Do not create segments (cosmetic gaps only)")
self.arg_parser.add_argument("--breakapart", type=inkex.Boolean, default=False, help="Performs CTRL + SHIFT + K to break the new output path into it's parts") pars.add_argument("--breakapart", type=inkex.Boolean, default=False, help="Performs CTRL + SHIFT + K to break the new output path into it's parts")
self.arg_parser.add_argument("--show_info", type=inkex.Boolean, default=False, help="Print some length and pattern information") pars.add_argument("--show_info", type=inkex.Boolean, default=False, help="Print some length and pattern information")
self.arg_parser.add_argument("--skip_errors", type=inkex.Boolean, default=False, help="Skip errors") pars.add_argument("--skip_errors", type=inkex.Boolean, default=False, help="Skip errors")
def breakContours(self, node, breakNodes = None): #this does the same as "CTRL + SHIFT + K" def breakContours(self, node, breakNodes = None): #this does the same as "CTRL + SHIFT + K"
if breakNodes == None: if breakNodes == None:

View File

@ -33,7 +33,6 @@ class DelaunayTriangulation(inkex.EffectExtension):
'Overlay selected objects with triangles.' 'Overlay selected objects with triangles.'
def add_arguments(self, pars): def add_arguments(self, pars):
'Parse the arguments passed to us from an Inkscape dialog box.'
pars.add_argument('--tab', help='The selected UI tab when OK was pressed') pars.add_argument('--tab', help='The selected UI tab when OK was pressed')
pars.add_argument('--joggling', type=inkex.Boolean, default=False, help='Use joggled input instead of merged facets') pars.add_argument('--joggling', type=inkex.Boolean, default=False, help='Use joggled input instead of merged facets')
pars.add_argument('--furthest', type=inkex.Boolean, default=False, help='Furthest-site Delaunay triangulation') pars.add_argument('--furthest', type=inkex.Boolean, default=False, help='Furthest-site Delaunay triangulation')

View File

@ -41,21 +41,21 @@ def rotate(tangentvec, point):
class Dimensioning(inkex.EffectExtension): class Dimensioning(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self) def add_arguments(self, pars):
# the options given in the dialouge pars.add_argument("--orientation", default='horizontal', help="The type of orientation of the dimensioning (horizontal, vertical or parallel)")
self.arg_parser.add_argument("--orientation", default='horizontal', help="The type of orientation of the dimensioning (horizontal, vertical or parallel)") pars.add_argument("--arrow_orientation", default='auto', help="The type of orientation of the arrows")
self.arg_parser.add_argument("--arrow_orientation", default='auto', help="The type of orientation of the arrows") pars.add_argument("--line_scale", type=float, default=1.0, help="Scale factor for the line thickness")
self.arg_parser.add_argument("--line_scale", type=float, default=1.0, help="Scale factor for the line thickness") pars.add_argument("--overlap", type=float, default=1.0, help="Overlap of the helpline over the dimensioning line")
self.arg_parser.add_argument("--overlap", type=float, default=1.0, help="Overlap of the helpline over the dimensioning line") pars.add_argument("--distance", type=float, default=1.0, help="Distance of the helpline to the object")
self.arg_parser.add_argument("--distance", type=float, default=1.0, help="Distance of the helpline to the object") pars.add_argument("--position", type=float, default=1.0, help="position of the dimensioning line")
self.arg_parser.add_argument("--position", type=float, default=1.0, help="position of the dimensioning line") pars.add_argument("--flip", type=inkex.Boolean, default=False, help="flip side")
self.arg_parser.add_argument("--flip", type=inkex.Boolean, default=False, help="flip side") pars.add_argument("--scale_factor", type=float, default=1.0, help="scale factor for the dimensioning text")
self.arg_parser.add_argument("--scale_factor", type=float, default=1.0, help="scale factor for the dimensioning text") pars.add_argument("--unit", default='px', help="The unit that should be used for the dimensioning")
self.arg_parser.add_argument("--unit", default='px', help="The unit that should be used for the dimensioning") pars.add_argument("--rotate", type=inkex.Boolean, default=True, help="Rotate the annotation?")
self.arg_parser.add_argument("--rotate", type=inkex.Boolean, default=True, help="Rotate the annotation?") pars.add_argument("--digit", type=int, default=0, help="number of digits after the point")
self.arg_parser.add_argument("--digit", type=int, default=0, help="number of digits after the point") pars.add_argument("--tab", default="sampling", help="The selected UI-tab when OK was pressed")
self.arg_parser.add_argument("--tab", default="sampling", help="The selected UI-tab when OK was pressed")
def create_linestyles(self): def create_linestyles(self):
''' '''
Create the line styles for the drawings. Create the line styles for the drawings.

View File

@ -5,9 +5,9 @@ from inkex import bezier
from inkex.paths import Path, CubicSuperPath from inkex.paths import Path, CubicSuperPath
class DistortionExtension(inkex.EffectExtension): class DistortionExtension(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self) def add_arguments(self, pars):
self.arg_parser.add_argument("--lambda_coef", type=float, default=-5.0, help="command line help") pars.add_argument("--lambda_coef", type=float, default=-5.0, help="command line help")
def distort_coordinates(self, x, y): def distort_coordinates(self, x, y):
"""Method applies barrel distorsion to given points with distorsion center in center of image, selected to """Method applies barrel distorsion to given points with distorsion center in center of image, selected to
@ -29,8 +29,6 @@ class DistortionExtension(inkex.EffectExtension):
y_d += self.y_c y_d += self.y_c
return x_d, y_d return x_d, y_d
def split_into_nodes(self, nodes_number=1000): def split_into_nodes(self, nodes_number=1000):
for id, node in self.svg.selected.items(): for id, node in self.svg.selected.items():
if node.tag == inkex.addNS('path', 'svg'): if node.tag == inkex.addNS('path', 'svg'):
@ -61,6 +59,9 @@ class DistortionExtension(inkex.EffectExtension):
) )
self.split_into_nodes() self.split_into_nodes()
self.q = self.options.lambda_coef self.q = self.options.lambda_coef
if self.q == 0.0:
inkex.errormsg("Invalid lambda coefficient. May not be exactly zero.")
return
nodes = [] nodes = []
for id, node in self.svg.selected.items(): for id, node in self.svg.selected.items():
if node.tag == inkex.addNS('path', 'svg'): if node.tag == inkex.addNS('path', 'svg'):

View File

@ -25,11 +25,11 @@ Foundation, Inc., 51 Fraanklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import inkex import inkex
class Pathpoints2Dots(inkex.EffectExtension): class Pathpoints2Dots(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self) def add_arguments(self, pars):
self.arg_parser.add_argument("--tab") pars.add_argument("--tab")
self.arg_parser.add_argument("--endpoints", type=inkex.Boolean, default=True) pars.add_argument("--endpoints", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--controlpoints", type=inkex.Boolean, default=False) pars.add_argument("--controlpoints", type=inkex.Boolean, default=False)
def effect(self): def effect(self):
if len(self.svg.selected) != 2: if len(self.svg.selected) != 2:

View File

@ -11,9 +11,8 @@ class StartEndPoints(inkex.EffectExtension):
startCircle = group.add(Circle(cx=str(point[0]), cy=str(point[1]), r=str(self.svg.unittouu(str(self.options.dotsize/2) + "px")))) startCircle = group.add(Circle(cx=str(point[0]), cy=str(point[1]), r=str(self.svg.unittouu(str(self.options.dotsize/2) + "px"))))
startCircle.style = style startCircle.style = style
def __init__(self): def add_arguments(self, pars):
inkex.Effect.__init__(self) pars.add_argument("--dotsize", type=int, default=10, help="Dot size (px) for self-intersecting points")
self.arg_parser.add_argument("--dotsize", type=int, default=10, help="Dot size (px) for self-intersecting points")
def effect(self): def effect(self):
dot_group = self.svg.add(inkex.Group()) dot_group = self.svg.add(inkex.Group())

View File

@ -253,21 +253,19 @@ class SpiroSine(inkex.EffectExtension):
nsURI = 'http://sample.com/ns' nsURI = 'http://sample.com/ns'
nsPrefix = 'doof' nsPrefix = 'doof'
def __init__(self): def add_arguments(self, pars):
pars.add_argument("--tab", help="The active tab when Apply was pressed")
inkex.Effect.__init__(self) pars.add_argument('--fCycles', type=float, default=10.0, help='Number of cycles (periods)')
self.arg_parser.add_argument("--tab", help="The active tab when Apply was pressed") pars.add_argument('--nrN', type=int, default=0, help='Start x at 2 * pi * n / m')
self.arg_parser.add_argument('--fCycles', type=float, default=10.0, help='Number of cycles (periods)') pars.add_argument('--nrM', type=int, default=0, help='Start x at 2 * pi * n / m')
self.arg_parser.add_argument('--nrN', type=int, default=0, help='Start x at 2 * pi * n / m') pars.add_argument('--fRecess', type=float, default=2.0, help='Recede from envelope by factor')
self.arg_parser.add_argument('--nrM', type=int, default=0, help='Start x at 2 * pi * n / m') pars.add_argument("--nSamples", type=int, default=50.0, help="Number of points to sample")
self.arg_parser.add_argument('--fRecess', type=float, default=2.0, help='Recede from envelope by factor') pars.add_argument("--nWidth", type=int, default=3200, help="Width in pixels")
self.arg_parser.add_argument("--nSamples", type=int, default=50.0, help="Number of points to sample") pars.add_argument("--nHeight", type=int, default=100, help="Height in pixels")
self.arg_parser.add_argument("--nWidth", type=int, default=3200, help="Width in pixels") pars.add_argument("--nOffsetX", type=int, default=0, help="Starting x coordinate (pixels)")
self.arg_parser.add_argument("--nHeight", type=int, default=100, help="Height in pixels") pars.add_argument("--nOffsetY", type=int, default=400, help="Starting y coordinate (pixels)")
self.arg_parser.add_argument("--nOffsetX", type=int, default=0, help="Starting x coordinate (pixels)") pars.add_argument('--bLace', type=inkex.Boolean, default=False, help='Lace')
self.arg_parser.add_argument("--nOffsetY", type=int, default=400, help="Starting y coordinate (pixels)") pars.add_argument('--bSpline', type=inkex.Boolean, default=True, help='Spline')
self.arg_parser.add_argument('--bLace', type=inkex.Boolean, default=False, help='Lace')
self.arg_parser.add_argument('--bSpline', type=inkex.Boolean, default=True, help='Spline')
self.recess = 0.95 self.recess = 0.95

View File

@ -90,11 +90,9 @@ def distanceSquared(p1, p2):
class Twist(inkex.EffectExtension): class Twist(inkex.EffectExtension):
def __init__(self): def add_arguments(self, pars):
pars.add_argument("--nSteps", type=int, default=8, help="Number of iterations to take")
inkex.Effect.__init__(self) pars.add_argument("--fRatio", type=float, default=0.2, help="Some ratio")
self.arg_parser.add_argument("--nSteps", type=int, default=8, help="Number of iterations to take")
self.arg_parser.add_argument("--fRatio", type=float, default=0.2, help="Some ratio")
""" """
Store each path in an associative array (dictionary) indexed Store each path in an associative array (dictionary) indexed

View File

@ -32,8 +32,6 @@ import math
from math import sqrt from math import sqrt
class EllipseSolveEffect(inkex.EffectExtension): class EllipseSolveEffect(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self)
def effect(self): def effect(self):
if len(self.svg.selected) == 0: if len(self.svg.selected) == 0:

View File

@ -33,8 +33,6 @@ import sys
from lxml import etree from lxml import etree
class EraserLayer(inkex.EffectExtension): class EraserLayer(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self)
#inserta el flltro que pasa a negro la mascara #inserta el flltro que pasa a negro la mascara
def insertFilter(self, svg): def insertFilter(self, svg):

View File

@ -7,11 +7,11 @@ import inkex
from inkex.paths import CubicSuperPath from inkex.paths import CubicSuperPath
class TransformExponential(inkex.EffectExtension): class TransformExponential(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self) def add_arguments(self, pars):
#self.arg_parser.add_argument('-a', '--axis', default='x', help='distortion axis. Valid values are "x", "y", or "xy". Default is "x"') #pars.add_argument('-a', '--axis', default='x', help='distortion axis. Valid values are "x", "y", or "xy". Default is "x"')
self.arg_parser.add_argument('-x', '--exponent', type=float, default=1.3, help='distortion factor. 1=no distortion, default 1.3') pars.add_argument('-x', '--exponent', type=float, default=1.3, help='distortion factor. 1=no distortion, default 1.3')
self.arg_parser.add_argument('-p', '--padding_perc', type=float, default=0, help='pad at origin. Padding 100% runs the exponential curve through [0.5 .. 1.0] -- default 0% runs through [0.0 .. 1.0]') pars.add_argument('-p', '--padding_perc', type=float, default=0, help='pad at origin. Padding 100% runs the exponential curve through [0.5 .. 1.0] -- default 0% runs through [0.0 .. 1.0]')
def x_exp(self, bbox, x): def x_exp(self, bbox, x):
""" reference implementation ignoring padding. unused. """ """ reference implementation ignoring padding. unused. """

View File

@ -23,6 +23,7 @@ GROUP_ID = 'export_selection_transform'
class ExportObject(inkex.EffectExtension): class ExportObject(inkex.EffectExtension):
def add_arguments(self, pars): def add_arguments(self, pars):
pars.add_argument("--wrap_transform", type=inkex.Boolean, default=False, help="Wrap final document in transform") pars.add_argument("--wrap_transform", type=inkex.Boolean, default=False, help="Wrap final document in transform")
pars.add_argument("--export_dir", default="~/inkscape_export/", help="Location to save exported documents") pars.add_argument("--export_dir", default="~/inkscape_export/", help="Location to save exported documents")

View File

@ -23,9 +23,6 @@ from inkex import transforms
class ExportXY(inkex.EffectExtension): class ExportXY(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self)
def effect(self): def effect(self):
if len(self.svg.selected) > 0: if len(self.svg.selected) > 0:
output_all = output_nodes = "" output_all = output_nodes = ""

View File

@ -64,12 +64,12 @@ def drawKthCircle(k,firstRadius,lastRadius,numNodes,spreadFactor,parent):
class FibonacciSpiral(inkex.EffectExtension): class FibonacciSpiral(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self) def add_arguments(self, pars):
self.arg_parser.add_argument("-f", "--FirstRadius", type=int, default="5", help="The radius of the first layer of circles in pixels.") pars.add_argument("-f", "--FirstRadius", type=int, default="5", help="The radius of the first layer of circles in pixels.")
self.arg_parser.add_argument("-l", "--LastRadius",type=int, default="10", help="The radius of the last layer of circles in pixels.") pars.add_argument("-l", "--LastRadius", type=int, default="10", help="The radius of the last layer of circles in pixels.")
self.arg_parser.add_argument("-n", "--NumberOfNodes", type=int, default="5", help="The number of layers in the fibonacci spiral") pars.add_argument("-n", "--NumberOfNodes", type=int, default="5", help="The number of layers in the fibonacci spiral")
self.arg_parser.add_argument("-s", "--SpreadFactor",type=int, default="10", help="This will create a larger spread between the nodes from the center.") pars.add_argument("-s", "--SpreadFactor",type=int, default="10", help="This will create a larger spread between the nodes from the center.")
def effect(self): def effect(self):
# Foreach Node # Foreach Node

View File

@ -37,11 +37,11 @@ def toFloat(l):
return l return l
class Circle(inkex.EffectExtension): class Circle(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self) def add_arguments(self, pars):
self.arg_parser.add_argument('--radius', type = float, default = 3.0, help = 'Radius to enter') pars.add_argument('--radius', type = float, default = 3.0, help = 'Radius to enter')
self.arg_parser.add_argument('--margin', type = float, default = 10.0, help = 'Margin between the edge of the rectangles and the circles') pars.add_argument('--margin', type = float, default = 10.0, help = 'Margin between the edge of the rectangles and the circles')
self.arg_parser.add_argument('--space', type = float, default = 30.0, help = 'Spacing between circles') pars.add_argument('--space', type = float, default = 30.0, help = 'Spacing between circles')
def effect(self): def effect(self):
# svg = self.svg.document.getroot() # svg = self.svg.document.getroot()

View File

@ -159,12 +159,12 @@ def d_str(self, useSandT=False, use_closed_attrib=False, rel=False):
return s if not rel else s.lower() return s if not rel else s.lower()
class FilletChamfer(inkex.EffectExtension): class FilletChamfer(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self) def add_arguments(self, pars):
self.arg_parser.add_argument("-t", "--fillet_type", default="fillet", help="Selects whether using fillet or chamfer") pars.add_argument("-t", "--fillet_type", default="fillet", help="Selects whether using fillet or chamfer")
self.arg_parser.add_argument("-R", "--radius", type=float, default=60.0, help="The radius") pars.add_argument("-R", "--radius", type=float, default=60.0, help="The radius")
self.arg_parser.add_argument('--unit', default='px', help='units of measurement') pars.add_argument('--unit', default='px', help='units of measurement')
self.arg_parser.add_argument("--remove", type=inkex.Boolean, default=False, help="If True, control object will be removed") pars.add_argument("--remove", type=inkex.Boolean, default=False, help="If True, control object will be removed")
def addEle(self, ele, parent, props): def addEle(self, ele, parent, props):
# https://inkscape.org/~pacogarcia/%E2%98%85new-version-of-shapes-extension # https://inkscape.org/~pacogarcia/%E2%98%85new-version-of-shapes-extension

View File

@ -33,9 +33,8 @@ import re
class FilterAndLiveEffectsLayer(inkex.EffectExtension): class FilterAndLiveEffectsLayer(inkex.EffectExtension):
def __init__(self): def add_arguments(self, pars):
inkex.Effect.__init__(self) pars.add_argument('--type', default = 'Add', help = 'Add or remove filters to current layer')
self.arg_parser.add_argument('--type', default = 'Add', help = 'Add or remove filters to current layer')
def selectTop(self): def selectTop(self):
selected = [] selected = []

View File

@ -13,8 +13,6 @@ import sys
def pout(t): sys.exit((gettext.gettext(t))) def pout(t): sys.exit((gettext.gettext(t)))
class root(inkex.EffectExtension): class root(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self)
def effect(self): def effect(self):
if len(self.svg.selected) == 0: pout("Please select at least one path.") if len(self.svg.selected) == 0: pout("Please select at least one path.")

View File

@ -109,13 +109,14 @@ def draw_ellipse_segment_rotated(cx,cy,rx,ry, width, fill, name, parent, rotatio
class Globe(inkex.EffectExtension): class Globe(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self) def add_arguments(self, pars):
self.arg_parser.add_argument("--longitudeLineCount", type=int, default=15, help="Number of longitude lines") pars.add_argument("--longitudeLineCount", type=int, default=15, help="Number of longitude lines")
self.arg_parser.add_argument("--latitudeLineCount", type=int, default=15, help="Number of latitude lines") pars.add_argument("--latitudeLineCount", type=int, default=15, help="Number of latitude lines")
self.arg_parser.add_argument("--rotationXDegrees", type=float, default=45, help="Rotation around X axis (degrees)") pars.add_argument("--rotationXDegrees", type=float, default=45, help="Rotation around X axis (degrees)")
self.arg_parser.add_argument("--rotationYDegrees", type=float, default=-45, help="Rotation around Y axis (degrees)") pars.add_argument("--rotationYDegrees", type=float, default=-45, help="Rotation around Y axis (degrees)")
self.arg_parser.add_argument("--isSeeThrough", type=inkex.Boolean, default=False, help="Is the globe see-through") pars.add_argument("--isSeeThrough", type=inkex.Boolean, default=False, help="Is the globe see-through")
def effect(self): def effect(self):
name = 'globe' name = 'globe'

View File

@ -50,18 +50,18 @@ def colorString(pickerColor):
return '#' + format(longcolor >> 8, '06X') return '#' + format(longcolor >> 8, '06X')
class Grid_Perspective(inkex.EffectExtension): class Grid_Perspective(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self) def add_arguments(self, pars):
self.arg_parser.add_argument("--size_unit", default="", help="Units for geometry") pars.add_argument("--size_unit", default="", help="Units for geometry")
self.arg_parser.add_argument("--width", type=int, default=500, help="Width of grid window") pars.add_argument("--width", type=int, default=500, help="Width of grid window")
self.arg_parser.add_argument("--height", type=int, default=300, help="Height of grid window") pars.add_argument("--height", type=int, default=300, help="Height of grid window")
self.arg_parser.add_argument("--p_divs", type=int, default=10, help="Number of divisions in perspective angle") pars.add_argument("--p_divs", type=int, default=10, help="Number of divisions in perspective angle")
self.arg_parser.add_argument("--horizon", type=float, default=150, help="Y coordinate of horizon") pars.add_argument("--horizon", type=float, default=150, help="Y coordinate of horizon")
self.arg_parser.add_argument("--left_x", type=float, default=-250, help="X coordinate of left perspective point") pars.add_argument("--left_x", type=float, default=-250, help="X coordinate of left perspective point")
self.arg_parser.add_argument("--right_x", type=float, default=750, help="X coordinate of right perspective point") pars.add_argument("--right_x", type=float, default=750, help="X coordinate of right perspective point")
self.arg_parser.add_argument("--div_th", type=float, default=2, help="Grid division line thickness") pars.add_argument("--div_th", type=float, default=2, help="Grid division line thickness")
self.arg_parser.add_argument("--div_color", type=int, help="Grid division line color") pars.add_argument("--div_color", type=int, help="Grid division line color")
self.arg_parser.add_argument("--border_th", type=float, default=3, help="Border Line thickness") pars.add_argument("--border_th", type=float, default=3, help="Border Line thickness")
def EdgePoints(self,x0, y0, theta): def EdgePoints(self,x0, y0, theta):
# find the intersection points of the line with the extended # find the intersection points of the line with the extended

View File

@ -30,23 +30,22 @@ def printDebug(string):
inkex.errormsg(string) inkex.errormsg(string)
class GridStrip_Creator(inkex.EffectExtension): class GridStrip_Creator(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self)
self.arg_parser.add_argument('--length', type = float, default = 230.0, help = 'Length of strip') def add_arguments(self, pars):
self.arg_parser.add_argument('--width', type = float, default = 20.0, help = 'Width of strip') pars.add_argument('--length', type = float, default = 230.0, help = 'Length of strip')
self.arg_parser.add_argument('--cellheight', type = float, default = 12.5, help = 'height of cell') pars.add_argument('--width', type = float, default = 20.0, help = 'Width of strip')
self.arg_parser.add_argument('--cellwidth', type = float, default = 12.5, help = 'Width of cell') pars.add_argument('--cellheight', type = float, default = 12.5, help = 'height of cell')
self.arg_parser.add_argument('--scalecells', type = inkex.Boolean, default = False, help = 'Scale cells over length') pars.add_argument('--cellwidth', type = float, default = 12.5, help = 'Width of cell')
self.arg_parser.add_argument('--cellnumx', type = int, default = 11, help = 'Number of cells x') pars.add_argument('--scalecells', type = inkex.Boolean, default = False, help = 'Scale cells over length')
self.arg_parser.add_argument('--cellnumy', type = int, default = 10, help = 'Number of cells y') pars.add_argument('--cellnumx', type = int, default = 11, help = 'Number of cells x')
self.arg_parser.add_argument('--notchdepth', type = float, default = 1.0, help = 'Depth of notch') pars.add_argument('--cellnumy', type = int, default = 10, help = 'Number of cells y')
self.arg_parser.add_argument('--notchwidth', type = float, default = 10.0, help = 'Width of notch') pars.add_argument('--notchdepth', type = float, default = 1.0, help = 'Depth of notch')
self.arg_parser.add_argument('--notchhorizontal', type = inkex.Boolean, default = False, help = 'Make notches on horizontal strip') pars.add_argument('--notchwidth', type = float, default = 10.0, help = 'Width of notch')
self.arg_parser.add_argument('--notchvertical', type = inkex.Boolean, default = False, help = 'Make notches on vertical strip') pars.add_argument('--notchhorizontal', type = inkex.Boolean, default = False, help = 'Make notches on horizontal strip')
self.arg_parser.add_argument('--notch2width', type = float, default = 3.0, help = 'Width of notch') pars.add_argument('--notchvertical', type = inkex.Boolean, default = False, help = 'Make notches on vertical strip')
self.arg_parser.add_argument('--notchxcorner', type = inkex.Boolean, default = False, help = 'Make notches on corner of horizontal strip') pars.add_argument('--notch2width', type = float, default = 3.0, help = 'Width of notch')
self.arg_parser.add_argument('--notchycorner', type = inkex.Boolean, default = False, help = 'Make notches on corner of vertical strip') pars.add_argument('--notchxcorner', type = inkex.Boolean, default = False, help = 'Make notches on corner of horizontal strip')
pars.add_argument('--notchycorner', type = inkex.Boolean, default = False, help = 'Make notches on corner of vertical strip')
def effect(self): def effect(self):
# Get access to main SVG document element and get its dimensions. # Get access to main SVG document element and get its dimensions.

View File

@ -25,9 +25,9 @@
import inkex import inkex
class GroupToLayerEffect(inkex.EffectExtension): class GroupToLayerEffect(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self) def add_arguments(self, pars):
self.arg_parser.add_argument('-d', '--depth', type = int, default = 1, help = 'Convert nested group up to DEPTH layers deep') pars.add_argument('-d', '--depth', type = int, default = 1, help = 'Convert nested group up to DEPTH layers deep')
def effect(self): def effect(self):
depth = self.options.depth depth = self.options.depth

View File

@ -41,6 +41,7 @@ import inkex
from inkex.command import inkscape from inkex.command import inkscape
class Guillotine(inkex.EffectExtension): class Guillotine(inkex.EffectExtension):
"""Exports slices made using guides""" """Exports slices made using guides"""
def add_arguments(self, pars): def add_arguments(self, pars):
pars.add_argument("--directory") pars.add_argument("--directory")

View File

@ -5,17 +5,17 @@ from inkex import TextElement, TextPath, Tspan
from inkex.bezier import csparea, cspcofm, csplength from inkex.bezier import csparea, cspcofm, csplength
from inkex.colors import Color from inkex.colors import Color
class IdsToText(inkex.Effect): class IdsToText(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self) def add_arguments(self, pars):
self.arg_parser.add_argument('--fontsize', type = int, default = '10', help = 'Font Size') pars.add_argument('--fontsize', type = int, default = '10', help = 'Font Size')
self.arg_parser.add_argument('--color', type=Color, default = 255, help = 'Color') pars.add_argument('--color', type=Color, default = 255, help = 'Color')
self.arg_parser.add_argument('--font', default = 'Roboto', help = 'Font Family') pars.add_argument('--font', default = 'Roboto', help = 'Font Family')
self.arg_parser.add_argument('--fontweight', default = 'bold', help = 'Font Weight') pars.add_argument('--fontweight', default = 'bold', help = 'Font Weight')
self.arg_parser.add_argument('--replaced', default = '', help = 'Text to replace') pars.add_argument('--replaced', default = '', help = 'Text to replace')
self.arg_parser.add_argument('--replacewith', default = '', help = 'Replace with this text') pars.add_argument('--replacewith', default = '', help = 'Replace with this text')
self.arg_parser.add_argument('--angle', type = float, dest = 'angle', default = 0, help = 'Rotation angle') pars.add_argument('--angle', type = float, dest = 'angle', default = 0, help = 'Rotation angle')
self.arg_parser.add_argument('--capitals', type = inkex.Boolean, default = False, help = 'Capitalize') pars.add_argument('--capitals', type = inkex.Boolean, default = False, help = 'Capitalize')
def effect(self): def effect(self):
if len(self.svg.selected) == 0: if len(self.svg.selected) == 0:

View File

@ -24,46 +24,45 @@ from math import *
from lxml import etree from lxml import etree
from inkex.paths import Path from inkex.paths import Path
class inkpacking(inkex.Effect): class inkpacking(inkex.EffectExtension):
def __init__(self): def add_arguments(self, pars):
inkex.Effect.__init__(self) pars.add_argument("--pages")
self.arg_parser.add_argument("--pages") pars.add_argument("--dustpages")
self.arg_parser.add_argument("--dustpages") pars.add_argument("--width", type=float, default=10.0)
self.arg_parser.add_argument("--width", type=float, default=10.0) pars.add_argument("--height", type=float, default=15.0)
self.arg_parser.add_argument("--height", type=float, default=15.0) pars.add_argument("--depth", type=float, default=3.0)
self.arg_parser.add_argument("--depth", type=float, default=3.0) pars.add_argument("--unit", default="mm")
self.arg_parser.add_argument("--unit", default="mm") pars.add_argument("--topscheme", default="rwlf")
self.arg_parser.add_argument("--topscheme", default="rwlf") pars.add_argument("--botscheme", default="rwlf")
self.arg_parser.add_argument("--botscheme", default="rwlf") pars.add_argument("--paper_thickness", type=float, default=0.5)
self.arg_parser.add_argument("--paper_thickness", type=float, default=0.5) pars.add_argument("--tab_proportion", type=float, default=14, help="Inner tab propotion for upper tab")
self.arg_parser.add_argument("--tab_proportion", type=float, default=14, help="Inner tab propotion for upper tab") pars.add_argument("--lockroundradius", type=float, default=18, help="Lock Radius")
self.arg_parser.add_argument("--lockroundradius", type=float, default=18, help="Lock Radius") pars.add_argument("--clueflapsize", type=float, default=13, help="Clue Flap Size")
self.arg_parser.add_argument("--clueflapsize", type=float, default=13, help="Clue Flap Size") pars.add_argument("--clueflapangle", type=float, default=12, help="Clue Flap Angle")
self.arg_parser.add_argument("--clueflapangle", type=float, default=12, help="Clue Flap Angle") pars.add_argument("--clueflapside", type=inkex.Boolean, default=False)
self.arg_parser.add_argument("--clueflapside", type=inkex.Boolean, default=False) pars.add_argument("--tfal", type=inkex.Boolean, default=False)
self.arg_parser.add_argument("--tfal", type=inkex.Boolean, default=False) pars.add_argument("--bfal", type=inkex.Boolean, default=False)
self.arg_parser.add_argument("--bfal", type=inkex.Boolean, default=False) pars.add_argument("--hotmeltprop", type=float, default=0.6)
self.arg_parser.add_argument("--hotmeltprop", type=float, default=0.6) pars.add_argument("--createshapes", type=inkex.Boolean, default=False)
self.arg_parser.add_argument("--createshapes", type=inkex.Boolean, default=False) pars.add_argument("--createglueshapes", type=inkex.Boolean, default=False)
self.arg_parser.add_argument("--createglueshapes", type=inkex.Boolean, default=False) pars.add_argument("--fingergrepa", type=inkex.Boolean, default=False)
self.arg_parser.add_argument("--fingergrepa", type=inkex.Boolean, default=False) pars.add_argument("--fingergrepb", type=inkex.Boolean, default=False)
self.arg_parser.add_argument("--fingergrepb", type=inkex.Boolean, default=False) pars.add_argument("--fingergrepr", type=float, default=5)
self.arg_parser.add_argument("--fingergrepr", type=float, default=5) pars.add_argument("--usetop", type=inkex.Boolean, default=False)
self.arg_parser.add_argument("--usetop", type=inkex.Boolean, default=False) pars.add_argument("--glueflapinoff", type=float, default=0)
self.arg_parser.add_argument("--glueflapinoff", type=float, default=0) pars.add_argument("--glueflapin45", type=float, default=2)
self.arg_parser.add_argument("--glueflapin45", type=float, default=2) pars.add_argument("--glueflapinang", type=float, default=7)
self.arg_parser.add_argument("--glueflapinang", type=float, default=7) pars.add_argument("--glueflapouoff", type=float, default=0)
self.arg_parser.add_argument("--glueflapouoff", type=float, default=0) pars.add_argument("--glueflapou45", type=float, default=3)
self.arg_parser.add_argument("--glueflapou45", type=float, default=3) pars.add_argument("--glueflapouang", type=float, default=12)
self.arg_parser.add_argument("--glueflapouang", type=float, default=12) pars.add_argument("--bglueflapinoff", type=float, default=0)
self.arg_parser.add_argument("--bglueflapinoff", type=float, default=0) pars.add_argument("--bglueflapin45", type=float, default=2)
self.arg_parser.add_argument("--bglueflapin45", type=float, default=2) pars.add_argument("--bglueflapinang", type=float, default=7)
self.arg_parser.add_argument("--bglueflapinang", type=float, default=7) pars.add_argument("--bglueflapouoff", type=float, default=0)
self.arg_parser.add_argument("--bglueflapouoff", type=float, default=0) pars.add_argument("--bglueflapou45", type=float, default=3)
self.arg_parser.add_argument("--bglueflapou45", type=float, default=3) pars.add_argument("--bglueflapouang", type=float, default=12)
self.arg_parser.add_argument("--bglueflapouang", type=float, default=12) pars.add_argument("--roto", type=float, default=0)
self.arg_parser.add_argument("--roto", type=float, default=0)
def effect(self): def effect(self):
docW = self.svg.unittouu(self.document.getroot().get('width')) docW = self.svg.unittouu(self.document.getroot().get('width'))

View File

@ -357,22 +357,21 @@ def splitAt(string, length):
class InventorySticker(inkex.Effect): class InventorySticker(inkex.Effect):
def __init__(self): def add_arguments(self, pars):
inkex.Effect.__init__(self) pars.add_argument("--main_tabs")
self.arg_parser.add_argument("--main_tabs") pars.add_argument("--server_address", default="https://the.domain.de/items.csv")
self.arg_parser.add_argument("--server_address", default="https://the.domain.de/items.csv") pars.add_argument("--htuser", default="user")
self.arg_parser.add_argument("--htuser", default="user") pars.add_argument("--htpassword", default="password")
self.arg_parser.add_argument("--htpassword", default="password") pars.add_argument("--sticker_ids", default="*")
self.arg_parser.add_argument("--sticker_ids", default="*") pars.add_argument("--target_url", default="qwa.es")
self.arg_parser.add_argument("--target_url", default="qwa.es") pars.add_argument("--target_owner", default="Stadtfabrikanten e.V.")
self.arg_parser.add_argument("--target_owner", default="Stadtfabrikanten e.V.") pars.add_argument("--export_dir", default="/home/")
self.arg_parser.add_argument("--export_dir", default="/home/") pars.add_argument("--flat_export", type=inkex.Boolean, default=False)
self.arg_parser.add_argument("--flat_export", type=inkex.Boolean, default=False) pars.add_argument("--preview", type=inkex.Boolean, default=False)
self.arg_parser.add_argument("--preview", type=inkex.Boolean, default=False) pars.add_argument("--export_svg", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--export_svg", type=inkex.Boolean, default=True) pars.add_argument("--export_png", type=inkex.Boolean, default=False)
self.arg_parser.add_argument("--export_png", type=inkex.Boolean, default=False) pars.add_argument("--print_png", type=int, default=0)
self.arg_parser.add_argument("--print_png", type=int, default=0) pars.add_argument("--print_device", default="04f9:2044")
self.arg_parser.add_argument("--print_device", default="04f9:2044")
def effect(self): def effect(self):
# Adjust the document view for the desired sticker size # Adjust the document view for the desired sticker size

View File

@ -104,12 +104,11 @@ def getArrangedIds(pathMap, startPathId):
nextPathId = closestId nextPathId = closestId
return orderPathIds return orderPathIds
class JoinPathsOptimEffect(inkex.Effect): class JoinPathsOptimEffect(inkex.EffectExtension):
def __init__(self): def add_arguments(self, pars):
inkex.Effect.__init__(self) pars.add_argument("--optimized", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--optimized", type=inkex.Boolean, default=True) pars.add_argument("--tab", default="sampling", help="Tab")
self.arg_parser.add_argument("--tab", default="sampling", help="Tab")
def effect(self): def effect(self):
selections = self.svg.selected selections = self.svg.selected

View File

@ -26,17 +26,15 @@ import shutil
inkex.localization.localize inkex.localization.localize
class JPEGExport(inkex.Effect): class JPEGExport(inkex.EffectExtension):
def __init__(self): def add_arguments(self, pars):
inkex.Effect.__init__(self) pars.add_argument("--path", default="")
pars.add_argument("--bgcol", default="#ffffff")
self.arg_parser.add_argument("--path", default="") pars.add_argument("--quality",type=int, default="90")
self.arg_parser.add_argument("--bgcol", default="#ffffff") pars.add_argument("--density", type=int, default="90")
self.arg_parser.add_argument("--quality",type=int, default="90") pars.add_argument("--page", type=inkex.Boolean, default=False)
self.arg_parser.add_argument("--density", type=int, default="90") pars.add_argument("--fast", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--page", type=inkex.Boolean, default=False)
self.arg_parser.add_argument("--fast", type=inkex.Boolean, default=True)
def effect(self): def effect(self):
"""get selected item coords and call command line command to export as a png""" """get selected item coords and call command line command to export as a png"""

View File

@ -26,9 +26,7 @@ import inkex
from inkex.paths import CubicSuperPath, Path from inkex.paths import CubicSuperPath, Path
from lxml import etree from lxml import etree
class LabelColour(inkex.Effect): class LabelColour(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self)
def effect(self): def effect(self):
if len(self.svg.selected) > 0: if len(self.svg.selected) > 0:

View File

@ -22,9 +22,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import inkex import inkex
from inkex.localization import inkex_gettext as _ from inkex.localization import inkex_gettext as _
class Mirror(inkex.Effect): class Mirror(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self)
def effect(self): def effect(self):
if len(self.options.ids) < 2: if len(self.options.ids) < 2:

View File

@ -15,10 +15,7 @@ def error(message):
inkex.errormsg(message) inkex.errormsg(message)
exit() exit()
class MultiCutEffect(inkex.Effect): class MultiCutEffect(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self)
def effect(self): def effect(self):
if len(self.svg.selected.items()) != 2: if len(self.svg.selected.items()) != 2:

View File

@ -28,11 +28,11 @@ import cubicsuperpath
from lxml import etree from lxml import etree
from inkex.paths import Path, CubicSuperPath from inkex.paths import Path, CubicSuperPath
class RadiusRandomize(inkex.Effect): class Netting(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self) def add_arguments(self, pars):
self.arg_parser.add_argument("--s_width", type=float, default=1.0, help="stroke width") pars.add_argument("--s_width", type=float, default=1.0, help="stroke width")
self.arg_parser.add_argument("--title") pars.add_argument("--title")
def effect(self): def effect(self):
path_strings = [] path_strings = []
@ -57,4 +57,4 @@ class RadiusRandomize(inkex.Effect):
self.svg.get_current_layer().append( my_path ) self.svg.get_current_layer().append( my_path )
if __name__ == '__main__': if __name__ == '__main__':
RadiusRandomize().run() Netting().run()

View File

@ -6,19 +6,19 @@ from inkex.paths import CubicSuperPath
import re import re
import pyclipper import pyclipper
class ofsplot(inkex.Effect): class ofsplot(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self) def add_arguments(self, pars):
self.arg_parser.add_argument('--unit') pars.add_argument('--unit')
self.arg_parser.add_argument("--offset_count", type=int, default=1, help="Number of offset paths") pars.add_argument("--offset_count", type=int, default=1, help="Number of offset paths")
self.arg_parser.add_argument("--offset", type=float, default=1.000, help="Offset amount") pars.add_argument("--offset", type=float, default=1.000, help="Offset amount")
self.arg_parser.add_argument("--init_offset", type=float, default=0.000, help="Initial Offset Amount") pars.add_argument("--init_offset", type=float, default=0.000, help="Initial Offset Amount")
self.arg_parser.add_argument("--copy_org", type=inkex.Boolean, default=True, help="copy original path") pars.add_argument("--copy_org", type=inkex.Boolean, default=True, help="copy original path")
self.arg_parser.add_argument("--offset_increase", type=float, default=0.000, help="Offset increase between iterations") pars.add_argument("--offset_increase", type=float, default=0.000, help="Offset increase between iterations")
self.arg_parser.add_argument("--jointype", default="2", help="Join type") pars.add_argument("--jointype", default="2", help="Join type")
self.arg_parser.add_argument("--endtype", default="3", help="End type") pars.add_argument("--endtype", default="3", help="End type")
self.arg_parser.add_argument("--miterlimit", type=float, default=3.0, help="Miter limit") pars.add_argument("--miterlimit", type=float, default=3.0, help="Miter limit")
self.arg_parser.add_argument("--clipperscale", type=float, default=1024.0, help="Scaling factor") pars.add_argument("--clipperscale", type=float, default=1024.0, help="Scaling factor")
def effect(self): def effect(self):
unit_factor = 1.0 / self.svg.uutounit(1.0,self.options.unit) unit_factor = 1.0 / self.svg.uutounit(1.0,self.options.unit)

View File

@ -516,19 +516,19 @@ def writeSVG(self, unfolding, size, printNumbers):
tspan.text = str(glueNumber[edge.idx()]) tspan.text = str(glueNumber[edge.idx()])
return paperfoldPageGroup return paperfoldPageGroup
class Unfold(inkex.Effect): class Unfold(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self) def add_arguments(self, pars):
self.arg_parser.add_argument("--inputfile") pars.add_argument("--inputfile")
self.arg_parser.add_argument("--printNumbers", type=inkex.Boolean, default=False, help="Print numbers on the cut edges") pars.add_argument("--printNumbers", type=inkex.Boolean, default=False, help="Print numbers on the cut edges")
self.arg_parser.add_argument("--scalefactor", type=float, default=1.0, help="Manual scale factor") pars.add_argument("--scalefactor", type=float, default=1.0, help="Manual scale factor")
self.arg_parser.add_argument("--resizetoimport", type=inkex.Boolean, default=True, help="Resize the canvas to the imported drawing's bounding box") pars.add_argument("--resizetoimport", type=inkex.Boolean, default=True, help="Resize the canvas to the imported drawing's bounding box")
self.arg_parser.add_argument("--extraborder", type=float, default=0.0) pars.add_argument("--extraborder", type=float, default=0.0)
self.arg_parser.add_argument("--extraborder_units") pars.add_argument("--extraborder_units")
self.arg_parser.add_argument("--color_valley_cut", type=Color, default='255', help="Color for valley cuts") pars.add_argument("--color_valley_cut", type=Color, default='255', help="Color for valley cuts")
self.arg_parser.add_argument("--color_mountain_cut", type=Color, default='1968208895', help="Color for mountain cuts") pars.add_argument("--color_mountain_cut", type=Color, default='1968208895', help="Color for mountain cuts")
self.arg_parser.add_argument("--color_valley_perforate", type=Color, default='3422552319', help="Color for valley perforations") pars.add_argument("--color_valley_perforate", type=Color, default='3422552319', help="Color for valley perforations")
self.arg_parser.add_argument("--color_mountain_perforate", type=Color, default='879076607', help="Color for mountain perforations") pars.add_argument("--color_mountain_perforate", type=Color, default='879076607', help="Color for mountain perforations")
def effect(self): def effect(self):
mesh = om.read_trimesh(self.options.inputfile) mesh = om.read_trimesh(self.options.inputfile)

View File

@ -30,6 +30,7 @@ import inkex
from inkex import turtle as pturtle from inkex import turtle as pturtle
class parabola(inkex.GenerateExtension): class parabola(inkex.GenerateExtension):
container_label = 'Parabola' container_label = 'Parabola'
def add_arguments(self, pars): def add_arguments(self, pars):
pars.add_argument("--height", type=int, default=300, help="Shape Height") pars.add_argument("--height", type=int, default=300, help="Shape Height")

View File

@ -25,16 +25,15 @@ import inkex
from inkex import bezier, Path, CubicSuperPath, PathElement from inkex import bezier, Path, CubicSuperPath, PathElement
class PasteLengthEffect(inkex.Effect): class PasteLengthEffect(inkex.EffectExtension):
def __init__(self): def add_arguments(self, pars):
inkex.Effect.__init__(self) pars.add_argument('--scale', type = float, default = '1', help = 'Additionally scale the length by')
self.arg_parser.add_argument('--scale', type = float, default = '1', help = 'Additionally scale the length by') pars.add_argument('--scaleFrom', default = 'center', help = 'Scale Path From')
self.arg_parser.add_argument('--scaleFrom', default = 'center', help = 'Scale Path From') pars.add_argument('--precision', type = int, default = '5', help = 'Number of significant digits')
self.arg_parser.add_argument('--precision', type = int, default = '5', help = 'Number of significant digits') pars.add_argument("--override_selection", type = inkex.Boolean, default = False, help = "Use a custom length instead using the length of the first object in selection")
self.arg_parser.add_argument("--override_selection", type = inkex.Boolean, default = False, help = "Use a custom length instead using the length of the first object in selection") pars.add_argument("--custom_length", type = float, default = 100.000, help = "Custom length")
self.arg_parser.add_argument("--custom_length", type = float, default = 100.000, help = "Custom length") pars.add_argument("--unit", default = "mm", help = "Units")
self.arg_parser.add_argument("--unit", default = "mm", help = "Units")
def scaleCubicSuper(self, cspath, scaleFactor, scaleFrom): def scaleCubicSuper(self, cspath, scaleFactor, scaleFrom):
bbox = Path(cspath).bounding_box() bbox = Path(cspath).bounding_box()

View File

@ -55,17 +55,17 @@ def roughBBox(path):
tn=(yMax-ymin)/(xMax-xmin) tn=(yMax-ymin)/(xMax-xmin)
return tn return tn
class Length(inkex.Effect): class Length(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self) def add_arguments(self, pars):
self.arg_parser.add_argument("-s", "--selection", default=True, help="select path with length or slant") pars.add_argument("-s", "--selection", default=True, help="select path with length or slant")
self.arg_parser.add_argument("-1", "--len1", type=float, default=12) pars.add_argument("-1", "--len1", type=float, default=12)
self.arg_parser.add_argument("-2", "--len2", type=float, default=25) pars.add_argument("-2", "--len2", type=float, default=25)
self.arg_parser.add_argument("-3", "--len3", type=float, default=40) pars.add_argument("-3", "--len3", type=float, default=40)
self.arg_parser.add_argument("-4", "--len4", type=float, default=60) pars.add_argument("-4", "--len4", type=float, default=60)
self.arg_parser.add_argument("-5", "--len5", type=float, default=60) pars.add_argument("-5", "--len5", type=float, default=60)
self.arg_parser.add_argument("-6", "--hor", type=float, default=0.2) pars.add_argument("-6", "--hor", type=float, default=0.2)
self.arg_parser.add_argument("-7", "--ver", type=float, default=10) pars.add_argument("-7", "--ver", type=float, default=10)
def effect(self): def effect(self):
# loop over all selected paths # loop over all selected paths

View File

@ -90,19 +90,18 @@ def colorFromKey(keyNumber):
""" """
return keys_color[keyNumber%12] return keys_color[keyNumber%12]
class SVGPianoScale (inkex.Effect): class SVGPianoScale (inkex.EffectExtension):
marker_radius_factor = 0.42 # position marker in X on piano key marker_radius_factor = 0.42 # position marker in X on piano key
marker_y_offset_factor = 0.92 # position marker in Y marker_y_offset_factor = 0.92 # position marker in Y
def __init__(self): def add_arguments(self, pars):
inkex.Effect.__init__(self) pars.add_argument("--firstNote", default="C1")
self.arg_parser.add_argument("--firstNote", default="C1") pars.add_argument("--lastNote", default="B2")
self.arg_parser.add_argument("--lastNote", default="B2") pars.add_argument("--tab")
self.arg_parser.add_argument("--tab") pars.add_argument("--intervals")
self.arg_parser.add_argument("--intervals") pars.add_argument("--keynote")
self.arg_parser.add_argument("--keynote") pars.add_argument("--scale", type=int)
self.arg_parser.add_argument("--scale", type=int) pars.add_argument("--helpSheet", type=int)
self.arg_parser.add_argument("--helpSheet", type=int)
def calculate_size_and_positions(self): def calculate_size_and_positions(self):
" Determine page size and define key dimensions " " Determine page size and define key dimensions "

View File

@ -49,20 +49,19 @@ def hex_to_int_color(v):
assert(len(v) == 6) assert(len(v) == 6)
return int(v[:2], 16), int(v[2:4], 16), int(v[4:6], 16) return int(v[:2], 16), int(v[2:4], 16), int(v[4:6], 16)
class Pixel2SVG(inkex.Effect): class Pixel2SVG(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self) def add_arguments(self, pars):
# pixel2svg options pars.add_argument("-s", "--squaresize", type=int, default="5", help="Width and height of vector squares in pixels")
self.arg_parser.add_argument("-s", "--squaresize", type=int, default="5", help="Width and height of vector squares in pixels") pars.add_argument("--transparency", type=inkex.Boolean, default=True, help="Convert transparency to 'fill-opacity'")
self.arg_parser.add_argument("--transparency", type=inkex.Boolean, default=True, help="Convert transparency to 'fill-opacity'") pars.add_argument("--overlap", type=inkex.Boolean, default=False, help="Overlap vector squares by 1px")
self.arg_parser.add_argument("--overlap", type=inkex.Boolean, default=False, help="Overlap vector squares by 1px") pars.add_argument("--offset_image", type=inkex.Boolean, default=True, help="Offset traced image")
self.arg_parser.add_argument("--offset_image", type=inkex.Boolean, default=True, help="Offset traced image") pars.add_argument("--delete_image", type=inkex.Boolean, default=False, help="Delete bitmap image")
self.arg_parser.add_argument("--delete_image", type=inkex.Boolean, default=False, help="Delete bitmap image") pars.add_argument("--maxsize", type=int, default="256", help="Max. image size (width or height)")
self.arg_parser.add_argument("--maxsize", type=int, default="256", help="Max. image size (width or height)") pars.add_argument("--verbose", type=inkex.Boolean, default=False)
self.arg_parser.add_argument("--verbose", type=inkex.Boolean, default=False) pars.add_argument("--color_mode", default="all", help="Which colors to trace.")
self.arg_parser.add_argument("--color_mode", default="all", help="Which colors to trace.") pars.add_argument("--color", default="FFFFFF", help="Special color")
self.arg_parser.add_argument("--color", default="FFFFFF", help="Special color") pars.add_argument("--tab")
self.arg_parser.add_argument("--tab")
def checkImagePath(self, node): def checkImagePath(self, node):
"""Embed the data of the selected Image Tag element""" """Embed the data of the selected Image Tag element"""

View File

@ -52,31 +52,30 @@ def svg_from_points(points,offset):
s+='Z' s+='Z'
return s return s
class Polygon(inkex.Effect): class Polygon(inkex.EffecExtension):
def __init__(self): def add_arguments(self, pars):
inkex.Effect.__init__(self) pars.add_argument('--page')
self.arg_parser.add_argument('--page') pars.add_argument('--unit', default='mm', help='Measure Units')
self.arg_parser.add_argument('--unit', default='mm', help='Measure Units') pars.add_argument('--o_type', type=int, default=1, help='Outer type')
self.arg_parser.add_argument('--o_type', type=int, default=1, help='Outer type') pars.add_argument('--o_radius',type=float, default=100, help='Outer Radius')
self.arg_parser.add_argument('--o_radius',type=float, default=100, help='Outer Radius') pars.add_argument('--o_edges', type=int, default=1, help='Outer edges')
self.arg_parser.add_argument('--o_edges', type=int, default=1, help='Outer edges') pars.add_argument('--o_r_type', type=int, default=1, help='Outer radius type')
self.arg_parser.add_argument('--o_r_type', type=int, default=1, help='Outer radius type') pars.add_argument('--o_offset',type=float, default=100, help='Outer Radius')
self.arg_parser.add_argument('--o_offset',type=float, default=100, help='Outer Radius') pars.add_argument('--i_type', type=int, default=1, help='Inner type')
self.arg_parser.add_argument('--i_type', type=int, default=1, help='Inner type') pars.add_argument('--i_radius',type=float, default=100, help='Inner Radius')
self.arg_parser.add_argument('--i_radius',type=float, default=100, help='Inner Radius') pars.add_argument('--i_edges', type=int, default=1, help='Inner edges')
self.arg_parser.add_argument('--i_edges', type=int, default=1, help='Inner edges') pars.add_argument('--i_r_type', type=int, default=1, help='Inner radius type')
self.arg_parser.add_argument('--i_r_type', type=int, default=1, help='Inner radius type') pars.add_argument('--i_offset',type=float, default=100, help='Outer Radius')
self.arg_parser.add_argument('--i_offset',type=float, default=100, help='Outer Radius') pars.add_argument('--kerf',type=float, default=0.5, help='Kerf (width) of cut')
self.arg_parser.add_argument('--kerf',type=float, default=0.5, help='Kerf (width) of cut') pars.add_argument('--spacing',type=float, default=0.5)
self.arg_parser.add_argument('--spacing',type=float, default=0.5) pars.add_argument('--color1', type=Color, default='1923076095')
self.arg_parser.add_argument('--color1', type=Color, default='1923076095') pars.add_argument('--color2', type=Color, default='4012452351')
self.arg_parser.add_argument('--color2', type=Color, default='4012452351') pars.add_argument('--intensity', type=int, default=1)
self.arg_parser.add_argument('--intensity', type=int, default=1) pars.add_argument('--speed', type=int, default=1)
self.arg_parser.add_argument('--speed', type=int, default=1) pars.add_argument('--pass_offset', type=int, default=1)
self.arg_parser.add_argument('--pass_offset', type=int, default=1) pars.add_argument('--displaylasertag', type=inkex.Boolean, default=False)
self.arg_parser.add_argument('--displaylasertag', type=inkex.Boolean, default=False) pars.add_argument('--lasertag', default="=pass%n:%s:%i:%c=")
self.arg_parser.add_argument('--lasertag', default="=pass%n:%s:%i:%c=")
def effect(self): def effect(self):
global parent,nomTab,equalTabs,thickness,kerf,correction global parent,nomTab,equalTabs,thickness,kerf,correction

View File

@ -29,28 +29,27 @@ import math
import inkex import inkex
from lxml import etree from lxml import etree
class Printing_Marks (inkex.Effect): class Printing_Marks (inkex.EffectExtension):
# Default parameters # Default parameters
stroke_width = 0.25 stroke_width = 0.25
def __init__(self): def add_arguments(self, pars):
inkex.Effect.__init__(self) pars.add_argument("--where_to_crop", default=True, help="Apply crop marks to...")
self.arg_parser.add_argument("--where_to_crop", default=True, help="Apply crop marks to...") pars.add_argument("--crop_marks", type=inkex.Boolean, default=True, help="Draw crop Marks?")
self.arg_parser.add_argument("--crop_marks", type=inkex.Boolean, default=True, help="Draw crop Marks?") pars.add_argument("--dotted_crop_marks", type=inkex.Boolean, default=True, help="Draw dotted crop Marks?")
self.arg_parser.add_argument("--dotted_crop_marks", type=inkex.Boolean, default=True, help="Draw dotted crop Marks?") pars.add_argument("--bleed_marks", type=inkex.Boolean, default=False, help="Draw Bleed Marks?")
self.arg_parser.add_argument("--bleed_marks", type=inkex.Boolean, default=False, help="Draw Bleed Marks?") pars.add_argument("--registration_marks", type=inkex.Boolean, default=False, help="Draw Registration Marks?")
self.arg_parser.add_argument("--registration_marks", type=inkex.Boolean, default=False, help="Draw Registration Marks?") pars.add_argument("--star_target", type=inkex.Boolean, default=False, help="Draw Star Target?")
self.arg_parser.add_argument("--star_target", type=inkex.Boolean, default=False, help="Draw Star Target?") pars.add_argument("--colour_bars", type=inkex.Boolean, default=False, help="Draw Colour Bars?")
self.arg_parser.add_argument("--colour_bars", type=inkex.Boolean, default=False, help="Draw Colour Bars?") pars.add_argument("--page_info", type=inkex.Boolean, default=False, help="Draw Page Information?")
self.arg_parser.add_argument("--page_info", type=inkex.Boolean, default=False, help="Draw Page Information?") pars.add_argument("--unit",default="px", help="Draw measurment")
self.arg_parser.add_argument("--unit",default="px", help="Draw measurment") pars.add_argument("--crop_offset", type=float, default=0, help="Offset")
self.arg_parser.add_argument("--crop_offset", type=float, default=0, help="Offset") pars.add_argument("--bleed_top", type=float, default=0, help="Bleed Top Size")
self.arg_parser.add_argument("--bleed_top", type=float, default=0, help="Bleed Top Size") pars.add_argument("--bleed_bottom", type=float, default=0, help="Bleed Bottom Size")
self.arg_parser.add_argument("--bleed_bottom", type=float, default=0, help="Bleed Bottom Size") pars.add_argument("--bleed_left", type=float, default=0, help="Bleed Left Size")
self.arg_parser.add_argument("--bleed_left", type=float, default=0, help="Bleed Left Size") pars.add_argument("--bleed_right",type=float, default=0, help="Bleed Right Size")
self.arg_parser.add_argument("--bleed_right",type=float, default=0, help="Bleed Right Size") pars.add_argument("--tab", help="The selected UI-tab when OK was pressed")
self.arg_parser.add_argument("--tab", help="The selected UI-tab when OK was pressed")
def addMarker(self): def addMarker(self):
svg = self.document.getroot() svg = self.document.getroot()

View File

@ -53,7 +53,8 @@ def to_complex(point):
exit(1) exit(1)
class QuickJoint(inkex.Effect): class QuickJoint(inkex.EffectExtension):
def add_arguments(self, pars): def add_arguments(self, pars):
pars.add_argument('-s', '--side', type=int, default=0, help='Object face to tabify') pars.add_argument('-s', '--side', type=int, default=0, help='Object face to tabify')
pars.add_argument('-n', '--numtabs', type=int, default=1, help='Number of tabs to add') pars.add_argument('-n', '--numtabs', type=int, default=1, help='Number of tabs to add')

View File

@ -45,17 +45,16 @@ def draw_SVG_circle(parent, r, cx, cy, name, style):
inkex.addNS('label','inkscape'): name} inkex.addNS('label','inkscape'): name}
circle = etree.SubElement(parent, inkex.addNS('circle','svg'), circ_attribs ) circle = etree.SubElement(parent, inkex.addNS('circle','svg'), circ_attribs )
class Ratchet(inkex.Effect): class Ratchet(inkex.EffectExtension):
def __init__(self): def add_arguments(self, pars):
inkex.Effect.__init__(self) pars.add_argument("--centre_hole", type=inkex.Boolean, default=True, help="Show or not")
self.arg_parser.add_argument("--centre_hole", type=inkex.Boolean, default=True, help="Show or not") pars.add_argument("--teeth", type=int, default=12, help="Number of teeth around outside")
self.arg_parser.add_argument("--teeth", type=int, default=12, help="Number of teeth around outside") pars.add_argument("--centre_hole_diam", type=float, default=1, help="Dia of central hole")
self.arg_parser.add_argument("--centre_hole_diam", type=float, default=1, help="Dia of central hole") pars.add_argument("--diam_in", type=float, default=28, help="Inner diamter of the Ratchet")
self.arg_parser.add_argument("--diam_in", type=float, default=28, help="Inner diamter of the Ratchet") pars.add_argument("--diam_out", type=float, default=30, help="Outer diamter of the Ratchet")
self.arg_parser.add_argument("--diam_out", type=float, default=30, help="Outer diamter of the Ratchet") pars.add_argument('--vtooth_shape', default='straight', help="Shape of tooth")
self.arg_parser.add_argument('--vtooth_shape', default='straight', help="Shape of tooth") pars.add_argument('--htooth_shape', default='curve', help="Shape of tooth")
self.arg_parser.add_argument('--htooth_shape', default='curve', help="Shape of tooth")
def effect(self): def effect(self):
Line_style = {'stroke':'#000000','stroke-width':self.svg.unittouu(str(0.1) + "mm"),'fill':'none'} Line_style = {'stroke':'#000000','stroke-width':self.svg.unittouu(str(0.1) + "mm"),'fill':'none'}

View File

@ -33,18 +33,18 @@ from lxml import etree
# - add ruler into current layer # - add ruler into current layer
# - add magnification e.g. 2:1 for small drawings # - add magnification e.g. 2:1 for small drawings
class Realscale(inkex.Effect): class Realscale(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self) def add_arguments(self, pars):
self.arg_parser.add_argument('--tab') pars.add_argument('--tab')
self.arg_parser.add_argument('--length', type=float, default=100.0, help='Length of scaling path in real-world units') pars.add_argument('--length', type=float, default=100.0, help='Length of scaling path in real-world units')
self.arg_parser.add_argument('--unit', default='cm', help='Real-world unit') pars.add_argument('--unit', default='cm', help='Real-world unit')
self.arg_parser.add_argument('--showscale', default='false', help='Show Scale Ruler') pars.add_argument('--showscale', default='false', help='Show Scale Ruler')
self.arg_parser.add_argument('--choosescale', default='all', help='Choose Scale') pars.add_argument('--choosescale', default='all', help='Choose Scale')
self.arg_parser.add_argument('--metric', default='1', help='Common metric scales') pars.add_argument('--metric', default='1', help='Common metric scales')
self.arg_parser.add_argument('--imperial',default='1', help='Common imperial scales') pars.add_argument('--imperial',default='1', help='Common imperial scales')
self.arg_parser.add_argument('--custom_scale', type=float, default=45, help='Custom scale') pars.add_argument('--custom_scale', type=float, default=45, help='Custom scale')
self.arg_parser.add_argument('--unitlength', type=int, default='1', help='Length of scale ruler') pars.add_argument('--unitlength', type=int, default='1', help='Length of scale ruler')
def calc_scale_center(self, p1x, p1y, p2x, p2y): def calc_scale_center(self, p1x, p1y, p2x, p2y):
""" Use straight line as scaling center. """ Use straight line as scaling center.

View File

@ -53,9 +53,7 @@ class FixedRadiusSearch():
return p return p
return result return result
class RemoveRedundant(inkex.Effect): class RemoveRedundant(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self)
def effect(self): def effect(self):
seenSegments = set() seenSegments = set()

View File

@ -23,34 +23,34 @@ import inkex
from lxml import etree from lxml import etree
from math import * from math import *
class Knob_Scale(inkex.Effect): class Knob_Scale(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self) def add_arguments(self, pars):
# General settings # General settings
self.arg_parser.add_argument("--x", type=float, default=0.0, help="Center X") pars.add_argument("--x", type=float, default=0.0, help="Center X")
self.arg_parser.add_argument("--y", type=float, default=0.0, help="Center Y") pars.add_argument("--y", type=float, default=0.0, help="Center Y")
self.arg_parser.add_argument("--radius", type=float, default=100.0, help="Knob radius") pars.add_argument("--radius", type=float, default=100.0, help="Knob radius")
self.arg_parser.add_argument("--linewidth", type=float, default=1) pars.add_argument("--linewidth", type=float, default=1)
self.arg_parser.add_argument("--angle", type=float, default=260.0, help="Angle of the knob scale in degrees") pars.add_argument("--angle", type=float, default=260.0, help="Angle of the knob scale in degrees")
self.arg_parser.add_argument("--draw_arc", type=inkex.Boolean, default='True') pars.add_argument("--draw_arc", type=inkex.Boolean, default='True')
self.arg_parser.add_argument("--draw_centering_circle", type=inkex.Boolean, default='False') pars.add_argument("--draw_centering_circle", type=inkex.Boolean, default='False')
self.arg_parser.add_argument("-u", "--units", default="px", help="units to measure size of knob") pars.add_argument("-u", "--units", default="px", help="units to measure size of knob")
# Tick settings # Tick settings
self.arg_parser.add_argument("--n_ticks", type=int, default=5) pars.add_argument("--n_ticks", type=int, default=5)
self.arg_parser.add_argument("--ticksize", type=float, default=10) pars.add_argument("--ticksize", type=float, default=10)
self.arg_parser.add_argument("--n_subticks", type=int, default=10) pars.add_argument("--n_subticks", type=int, default=10)
self.arg_parser.add_argument("--subticksize", type=float, default=5) pars.add_argument("--subticksize", type=float, default=5)
self.arg_parser.add_argument("--style", default='marks_outwards', help="Style of marks") pars.add_argument("--style", default='marks_outwards', help="Style of marks")
# Label settings # Label settings
self.arg_parser.add_argument("--labels_enabled", type=inkex.Boolean, default='False') pars.add_argument("--labels_enabled", type=inkex.Boolean, default='False')
self.arg_parser.add_argument("--rounding_level", type=int, default=0) pars.add_argument("--rounding_level", type=int, default=0)
self.arg_parser.add_argument("--text_size", type=float, default=1) pars.add_argument("--text_size", type=float, default=1)
self.arg_parser.add_argument("--text_offset", type=float, default=20) pars.add_argument("--text_offset", type=float, default=20)
self.arg_parser.add_argument("--start_value", type=float, default=0) pars.add_argument("--start_value", type=float, default=0)
self.arg_parser.add_argument("--stop_value", type=float, default=10) pars.add_argument("--stop_value", type=float, default=10)
# Dummy # Dummy
self.arg_parser.add_argument("--tab") pars.add_argument("--tab")
def draw_text(self, textvalue, radius, angular_position, text_size, parent): def draw_text(self, textvalue, radius, angular_position, text_size, parent):
# Create text element # Create text element

View File

@ -48,54 +48,50 @@ import math
import inkex import inkex
from lxml import etree from lxml import etree
class ScaleGen(inkex.Effect): class ScaleGen(inkex.EffectExtension):
def __init__(self):
# Call the base class constructor.
inkex.Effect.__init__(self)
def add_arguments(self, pars):
# Define string option "--what" with "-w" shortcut and default value "World". # Define string option "--what" with "-w" shortcut and default value "World".
self.arg_parser.add_argument('-f', '--scalefrom', type = int, default = '0', help = 'Number from...') pars.add_argument('-f', '--scalefrom', type = int, default = '0', help = 'Number from...')
self.arg_parser.add_argument('-t', '--scaleto', type = int,default = '20', help = 'Number to...') pars.add_argument('-t', '--scaleto', type = int,default = '20', help = 'Number to...')
self.arg_parser.add_argument('--mathexpression', default = '', help = 'Math expression') pars.add_argument('--mathexpression', default = '', help = 'Math expression')
self.arg_parser.add_argument('-c', '--reverse', default = 'false', help = 'Reverse order:') pars.add_argument('-c', '--reverse', default = 'false', help = 'Reverse order:')
self.arg_parser.add_argument('-p', '--type', default = 'false', help = 'Type:') pars.add_argument('-p', '--type', default = 'false', help = 'Type:')
self.arg_parser.add_argument('--radius', type = float, default = '100', help = 'Radius') pars.add_argument('--radius', type = float, default = '100', help = 'Radius')
self.arg_parser.add_argument('--scaleradcount', type = float, default = '90', help = 'Circular count') pars.add_argument('--scaleradcount', type = float, default = '90', help = 'Circular count')
self.arg_parser.add_argument('--scaleradbegin', type = float, default = '0', help = 'Circular begin') pars.add_argument('--scaleradbegin', type = float, default = '0', help = 'Circular begin')
self.arg_parser.add_argument('--radmark', default = 'True', help = 'Mark origin') pars.add_argument('--radmark', default = 'True', help = 'Mark origin')
self.arg_parser.add_argument('--insidetf', type = inkex.Boolean, default = 'False', help = 'Swap inside out') pars.add_argument('--insidetf', type = inkex.Boolean, default = 'False', help = 'Swap inside out')
self.arg_parser.add_argument('--ishorizontal', default = 'False', help = 'Horizontal labels') pars.add_argument('--ishorizontal', default = 'False', help = 'Horizontal labels')
self.arg_parser.add_argument('--rotate', default = '0', help = 'Rotate:') pars.add_argument('--rotate', default = '0', help = 'Rotate:')
self.arg_parser.add_argument('-b', '--units_per_line', type = float, default = '100', help = 'Units per line') pars.add_argument('-b', '--units_per_line', type = float, default = '100', help = 'Units per line')
self.arg_parser.add_argument('-g', '--labellinelength', type = float, default = '100', help = 'Label line - Length') pars.add_argument('-g', '--labellinelength', type = float, default = '100', help = 'Label line - Length')
self.arg_parser.add_argument('-s', '--fontsize', type = float, default = '3', help = 'Font Size:') pars.add_argument('-s', '--fontsize', type = float, default = '3', help = 'Font Size:')
self.arg_parser.add_argument('-i', '--suffix', default = '', help = 'Suffix:') pars.add_argument('-i', '--suffix', default = '', help = 'Suffix:')
self.arg_parser.add_argument('--drawalllabels', type = inkex.Boolean, default = 'True', help = 'Draw all labels') pars.add_argument('--drawalllabels', type = inkex.Boolean, default = 'True', help = 'Draw all labels')
self.arg_parser.add_argument('--fliplabel', type = inkex.Boolean, default = 'False', help = 'Flip orientation') pars.add_argument('--fliplabel', type = inkex.Boolean, default = 'False', help = 'Flip orientation')
self.arg_parser.add_argument('--labellinestrokewidth', type = float, default = '0.4', help = 'Label line - Stroke width') pars.add_argument('--labellinestrokewidth', type = float, default = '0.4', help = 'Label line - Stroke width')
self.arg_parser.add_argument('--longlinestrokewidth', type = float, default = '0.2', help = 'Long line - Stroke width') pars.add_argument('--longlinestrokewidth', type = float, default = '0.2', help = 'Long line - Stroke width')
self.arg_parser.add_argument('--shortlinestrokewidth', type = float, default = '0.2', help = 'Short line - Stroke width') pars.add_argument('--shortlinestrokewidth', type = float, default = '0.2', help = 'Short line - Stroke width')
self.arg_parser.add_argument('--perplinestrokewidth', type = float, default = '0.2', help = 'Perpendicular line - Stroke width') pars.add_argument('--perplinestrokewidth', type = float, default = '0.2', help = 'Perpendicular line - Stroke width')
# label offset # label offset
self.arg_parser.add_argument('-x', '--labeloffseth', type = float, default = '0', help = 'Label offset h:') pars.add_argument('-x', '--labeloffseth', type = float, default = '0', help = 'Label offset h:')
self.arg_parser.add_argument('-y', '--labeloffsetv', type = float, default = '-3.5', help = 'Label offset v:') pars.add_argument('-y', '--labeloffsetv', type = float, default = '-3.5', help = 'Label offset v:')
# line spacing # line spacing
self.arg_parser.add_argument('-m', '--mark0', type = int, default = '10', help = 'Label line - Draw every x lines:') pars.add_argument('-m', '--mark0', type = int, default = '10', help = 'Label line - Draw every x lines:')
self.arg_parser.add_argument('-n', '--mark1', type = int, default = '5', help = 'Long line - Draw every x lines') pars.add_argument('-n', '--mark1', type = int, default = '5', help = 'Long line - Draw every x lines')
self.arg_parser.add_argument('-o', '--mark2', type = int, default = '1', help = 'Short line - Draw every x lines') pars.add_argument('-o', '--mark2', type = int, default = '1', help = 'Short line - Draw every x lines')
# line length # line length
self.arg_parser.add_argument('-w', '--mark1wid', type = int, default = '75', help = 'Long line: - Length (units): (\%):') pars.add_argument('-w', '--mark1wid', type = int, default = '75', help = 'Long line: - Length (units): (\%):')
self.arg_parser.add_argument('-v', '--mark2wid', type = int, help = 'Short line: - Length (units): (\%):') pars.add_argument('-v', '--mark2wid', type = int, help = 'Short line: - Length (units): (\%):')
self.arg_parser.add_argument('-u', '--unit', default = 'mm', help = 'Unit:') pars.add_argument('-u', '--unit', default = 'mm', help = 'Unit:')
self.arg_parser.add_argument('--useref', type = inkex.Boolean, default = False, help = 'Reference is bounding box center') pars.add_argument('--useref', type = inkex.Boolean, default = False, help = 'Reference is bounding box center')
self.arg_parser.add_argument('--tab', default = 'global', help = '') pars.add_argument('--tab', default = 'global', help = '')
self.arg_parser.add_argument("--perpline", type=inkex.Boolean, default=True, help="Perpendicular line") pars.add_argument("--perpline", type=inkex.Boolean, default=True, help="Perpendicular line")
self.arg_parser.add_argument('--perplineoffset', type = float, default = '0', help = 'Offset') pars.add_argument('--perplineoffset', type = float, default = '0', help = 'Offset')
def addLabel(self, n, x, y, group, fontsize, phi = 0.0): def addLabel(self, n, x, y, group, fontsize, phi = 0.0):
mathexpression = self.options.mathexpression mathexpression = self.options.mathexpression

View File

@ -29,19 +29,18 @@ from inkex.styles import Style
def dirtyFormat(path): def dirtyFormat(path):
return str(path).replace('[','').replace(']','').replace(',','').replace('\'','') return str(path).replace('[','').replace(']','').replace(',','').replace('\'','')
class RobotBox(inkex.Effect): class RobotBox(inkex.EffectExtension):
def __init__(self): def add_arguments(self, pars):
inkex.Effect.__init__(self) pars.add_argument("-x", "--width", type=float, default=62.0, help="The Box Width - in the X dimension")
self.arg_parser.add_argument("-x", "--width", type=float, default=62.0, help="The Box Width - in the X dimension") pars.add_argument("-y", "--height", type=float, default=38.0, help="The Box Height - in the Y dimension")
self.arg_parser.add_argument("-y", "--height", type=float, default=38.0, help="The Box Height - in the Y dimension") pars.add_argument("-z", "--depth", type=float, default=23.0, help="The Box Depth - in the Z dimension")
self.arg_parser.add_argument("-z", "--depth", type=float, default=23.0, help="The Box Depth - in the Z dimension") pars.add_argument("-p", "--thickness", type=float, default=1.0, help="Paper thickness - important for thick carton")
self.arg_parser.add_argument("-p", "--thickness", type=float, default=1.0, help="Paper thickness - important for thick carton") pars.add_argument("-c", "--crampheight", type=float, default=1.0, help="Cramp ear height - render cramping ears and slots on the left and right walls (0 for no cramp)")
self.arg_parser.add_argument("-c", "--crampheight", type=float, default=1.0, help="Cramp ear height - render cramping ears and slots on the left and right walls (0 for no cramp)") pars.add_argument("-d", "--dashwidth", type=float, default=5.0, help="Bend line dash width")
self.arg_parser.add_argument("-d", "--dashwidth", type=float, default=5.0, help="Bend line dash width") pars.add_argument("-s", "--dashstep", type=float, default=5.0, help="Bend line dash step")
self.arg_parser.add_argument("-s", "--dashstep", type=float, default=5.0, help="Bend line dash step") pars.add_argument("-b", "--bendsurface", default="inner", help="Bend line surface (innder or outer) - depends on the way you will make actual bends")
self.arg_parser.add_argument("-b", "--bendsurface", default="inner", help="Bend line surface (innder or outer) - depends on the way you will make actual bends") pars.add_argument("-u", "--unit", default="mm", help="The unit of dimensions")
self.arg_parser.add_argument("-u", "--unit", default="mm", help="The unit of dimensions")
def effect(self): def effect(self):
width = self.svg.unittouu( str(self.options.width) + self.options.unit ) width = self.svg.unittouu( str(self.options.width) + self.options.unit )

View File

@ -26,20 +26,20 @@ import inkex
from inkex.paths import Path, CubicSuperPath from inkex.paths import Path, CubicSuperPath
import re import re
class svgRounder(inkex.Effect): class svgRounder(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self) def add_arguments(self, pars):
self.arg_parser.add_argument("--precision", type=int, default=3, help="Precision") pars.add_argument("--precision", type=int, default=3, help="Precision")
self.arg_parser.add_argument("--ctrl", type=inkex.Boolean, default = False, help="Round node handles") pars.add_argument("--ctrl", type=inkex.Boolean, default = False, help="Round node handles")
self.arg_parser.add_argument("--along", type=inkex.Boolean, default = True, help="Move handles following node movement") pars.add_argument("--along", type=inkex.Boolean, default = True, help="Move handles following node movement")
self.arg_parser.add_argument("--half", type=inkex.Boolean, default = False, help="Allow round to half if nearest") pars.add_argument("--half", type=inkex.Boolean, default = False, help="Allow round to half if nearest")
self.arg_parser.add_argument("--paths", type=inkex.Boolean, default = True, help="Affect to paths") pars.add_argument("--paths", type=inkex.Boolean, default = True, help="Affect to paths")
self.arg_parser.add_argument("--widthheight", type=inkex.Boolean, default = False, help="Affect to width and height of objects") pars.add_argument("--widthheight", type=inkex.Boolean, default = False, help="Affect to width and height of objects")
self.arg_parser.add_argument("--position", type=inkex.Boolean, default = False, help="Affect to position of objects") pars.add_argument("--position", type=inkex.Boolean, default = False, help="Affect to position of objects")
self.arg_parser.add_argument("--strokewidth", type=inkex.Boolean, default = False, help="Affect to stroke width of objects") pars.add_argument("--strokewidth", type=inkex.Boolean, default = False, help="Affect to stroke width of objects")
self.arg_parser.add_argument("--opacity", type=inkex.Boolean, default = False, help="Affect to global opacity of objects") pars.add_argument("--opacity", type=inkex.Boolean, default = False, help="Affect to global opacity of objects")
self.arg_parser.add_argument("--strokeopacity", type=inkex.Boolean, default = False, help="Affect to stroke opcacity of objects") pars.add_argument("--strokeopacity", type=inkex.Boolean, default = False, help="Affect to stroke opcacity of objects")
self.arg_parser.add_argument("--fillopacity", type=inkex.Boolean, default = False, help="Affect to fill opcacity of objects") pars.add_argument("--fillopacity", type=inkex.Boolean, default = False, help="Affect to fill opcacity of objects")
def roundFloat(self, n): def roundFloat(self, n):
if self.options.half: if self.options.half:

View File

@ -13,13 +13,13 @@ from inkex.styles import Style
# This extension can scale any object or path on X, Y or both axes. This addon is kind of obsolete because you can do the same from transforms menu # This extension can scale any object or path on X, Y or both axes. This addon is kind of obsolete because you can do the same from transforms menu
class ScaleToSize(inkex.Effect): class ScaleToSize(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self) def add_arguments(self, pars):
self.arg_parser.add_argument('--unit') pars.add_argument('--unit')
self.arg_parser.add_argument("--expected_size", type=float, default=1.0, help="The expected size of the object") pars.add_argument("--expected_size", type=float, default=1.0, help="The expected size of the object")
self.arg_parser.add_argument("--scale_type", default="Horizontal", help="Scale type (Uniform, Horizontal, Vertical)") pars.add_argument("--scale_type", default="Horizontal", help="Scale type (Uniform, Horizontal, Vertical)")
self.arg_parser.add_argument("--description") pars.add_argument("--description")
def effect(self): def effect(self):
unit_factor = 1.0 / self.svg.uutounit(1.0,self.options.unit) unit_factor = 1.0 / self.svg.uutounit(1.0,self.options.unit)

View File

@ -56,15 +56,14 @@ class SheetMetalConus(inkex.Effect):
'marker-start' : 'url(#ArrowDIN-start)', 'marker-start' : 'url(#ArrowDIN-start)',
'marker-end' : 'url(#ArrowDIN-end)' } 'marker-end' : 'url(#ArrowDIN-end)' }
def __init__(self): def add_arguments(self, pars):
inkex.Effect.__init__(self) # Call the base class constructor. pars.add_argument('-b', '--diaBase', type = float, dest = 'diaBase', default = 300.0, help = 'The diameter of the cones base.')
self.arg_parser.add_argument('-b', '--diaBase', type = float, dest = 'diaBase', default = 300.0, help = 'The diameter of the cones base.') pars.add_argument('-c', '--diaCut', type = float, default = 100.0, help = 'The diameter of cones cut (0.0 if cone is not cut.')
self.arg_parser.add_argument('-c', '--diaCut', type = float, default = 100.0, help = 'The diameter of cones cut (0.0 if cone is not cut.') pars.add_argument('-l', '--heightCone', type = float, default = 200.0, help = 'The height of the (cut) cone.')
self.arg_parser.add_argument('-l', '--heightCone', type = float, default = 200.0, help = 'The height of the (cut) cone.') pars.add_argument('-u', '--units', default = 'mm', help = 'The units in which the cone values are given. mm or in for real objects')
self.arg_parser.add_argument('-u', '--units', default = 'mm', help = 'The units in which the cone values are given. mm or in for real objects') pars.add_argument('-w', '--strokeWidth', type = float, default = 0.3, help = 'The line thickness in given unit. For laser cutting it should be rather small.')
self.arg_parser.add_argument('-w', '--strokeWidth', type = float, default = 0.3, help = 'The line thickness in given unit. For laser cutting it should be rather small.') pars.add_argument('-f', '--strokeColour', type=Color, default = 255, help = 'The line colour.')
self.arg_parser.add_argument('-f', '--strokeColour', type=Color, default = 255, help = 'The line colour.') pars.add_argument('-d', '--verbose', type = inkex.Boolean, default = False, help = 'Enable verbose output of calculated parameters. Used for debugging or is someone needs the calculated values.')
self.arg_parser.add_argument('-d', '--verbose', type = inkex.Boolean, default = False, help = 'Enable verbose output of calculated parameters. Used for debugging or is someone needs the calculated values.')
# Marker arrows # Marker arrows
def makeMarkerstyle(self, name, rotate): def makeMarkerstyle(self, name, rotate):

View File

@ -11,15 +11,14 @@ def addPathCommand(a, cmd):
for x in cmd: for x in cmd:
a.append(str(x)) a.append(str(x))
class SheriffStarEffect(inkex.Effect): class SheriffStarEffect(inkex.EffectExtension):
def __init__(self): def add_arguments(self, pars):
inkex.Effect.__init__(self) pars.add_argument('--tab')
self.arg_parser.add_argument('--tab') pars.add_argument('--points', type=int, default=5, help='Number of points (or sides)')
self.arg_parser.add_argument('--points', type=int, default=5, help='Number of points (or sides)') pars.add_argument('--star_tip_ratio', type=float, default=10, help='Star tip circle % (star tip circle radius as a percentage of the outer radius)')
self.arg_parser.add_argument('--star_tip_ratio', type=float, default=10, help='Star tip circle % (star tip circle radius as a percentage of the outer radius)') pars.add_argument('--inner_ratio', type=float, default=58, help='Inner circle % (inner radius as a percentage of the outer radius)')
self.arg_parser.add_argument('--inner_ratio', type=float, default=58, help='Inner circle % (inner radius as a percentage of the outer radius)') pars.add_argument('--show_inner_circle', type=inkex.Boolean, default=False, help='Show inner circle')
self.arg_parser.add_argument('--show_inner_circle', type=inkex.Boolean, default=False, help='Show inner circle')
def effect(self): def effect(self):
layer = self.svg.get_current_layer(); layer = self.svg.get_current_layer();

View File

@ -3,11 +3,11 @@ from io import StringIO
import inkex import inkex
from lxml import etree from lxml import etree
class SliderElectrodes(inkex.Effect): class SliderElectrodes(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self) def add_arguments(self, pars):
self.arg_parser.add_argument("-c", "--count", type=int, default=5, help="Number of electrodes") pars.add_argument("-c", "--count", type=int, default=5, help="Number of electrodes")
self.arg_parser.add_argument("-s", "--spikes", type=int, default=5, help="Number of spikes") pars.add_argument("-s", "--spikes", type=int, default=5, help="Number of spikes")
def genPathString(self, bounds, spikeWidth, first=False, last=False): def genPathString(self, bounds, spikeWidth, first=False, last=False):
s = StringIO() s = StringIO()

View File

@ -7,12 +7,12 @@ def isclosedac(p):
return abs(p.start-p.end) < 1e-6 return abs(p.start-p.end) < 1e-6
class Sieve(inkex.Effect): class SmallThingsFilter(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self) def add_arguments(self, pars):
self.arg_parser.add_argument('--unit') pars.add_argument('--unit')
self.arg_parser.add_argument('--threshold', type=float, help='Remove paths with an threshold smaller than this value') pars.add_argument('--threshold', type=float, help='Remove paths with an threshold smaller than this value')
self.arg_parser.add_argument('--measure', default="length") pars.add_argument('--measure', default="length")
def effect(self): def effect(self):
self.options.threshold = self.svg.unittouu(str(self.options.threshold) + self.svg.unit) self.options.threshold = self.svg.unittouu(str(self.options.threshold) + self.svg.unit)
@ -43,4 +43,4 @@ class Sieve(inkex.Effect):
pass pass
if __name__ == '__main__': if __name__ == '__main__':
Sieve().run() SmallThingsFilter().run()

View File

@ -25,15 +25,14 @@ import inkex
from inkex.paths import Arc, Curve, Horz, Line, Move, Quadratic, Smooth, TepidQuadratic, Vert, ZoneClose from inkex.paths import Arc, Curve, Horz, Line, Move, Quadratic, Smooth, TepidQuadratic, Vert, ZoneClose
class SnapObjects(inkex.Effect): class SnapObjects(inkex.EffectExtension):
"Snap the points on multiple paths towards each other." "Snap the points on multiple paths towards each other."
def __init__(self): def add_arguments(self, pars):
inkex.Effect.__init__(self) pars.add_argument('--max_dist', type=float, default=25.0, help='Maximum distance to be considered a "nearby" point')
self.arg_parser.add_argument('--max_dist', type=float, default=25.0, help='Maximum distance to be considered a "nearby" point') pars.add_argument('--controls', type=inkex.Boolean, default=True, help='Snap control points')
self.arg_parser.add_argument('--controls', type=inkex.Boolean, default=True, help='Snap control points') pars.add_argument('--ends', type=inkex.Boolean, default=True, help='Snap endpoints')
self.arg_parser.add_argument('--ends', type=inkex.Boolean, default=True, help='Snap endpoints') pars.add_argument('--first_only', type=inkex.Boolean, default=True, help='Modify only the first selected path')
self.arg_parser.add_argument('--first_only', type=inkex.Boolean, default=True, help='Modify only the first selected path')
def _bin_points(self): def _bin_points(self):
"Associate each path ID with a list of control points and a list of endpoints." "Associate each path ID with a list of control points and a list of endpoints."

View File

@ -6,13 +6,13 @@ import random
import inkex import inkex
from lxml import etree from lxml import etree
class SourceCodeText(inkex.Effect): class SourceCodeText(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self) def add_arguments(self, pars):
self.arg_parser.add_argument("--directory", default='~/', help="Default directory") pars.add_argument("--directory", default='~/', help="Default directory")
self.arg_parser.add_argument("--pattern", default='py', help="File extension pattern") pars.add_argument("--pattern", default='py', help="File extension pattern")
self.arg_parser.add_argument("--wordsperpara", type=int, default=0, help="Maximum words per paragraph") pars.add_argument("--wordsperpara", type=int, default=0, help="Maximum words per paragraph")
self.arg_parser.add_argument("--numparas", type=int, default=1, help="Number of paragraphs") pars.add_argument("--numparas", type=int, default=1, help="Number of paragraphs")
def text_generation(self): def text_generation(self):
#Get all the matching files. Then yield words one at a time. This can take a while if there are a lot of files, but shouldn't be too bad. #Get all the matching files. Then yield words one at a time. This can take a while if there are a lot of files, but shouldn't be too bad.

View File

@ -64,15 +64,14 @@ def floatCmpWithMargin(float1, float2, margin = DEF_ERR_MARGIN):
return abs(float1 - float2) < margin return abs(float1 - float2) < margin
class SubdividePathEffect(inkex.Effect): class SubdividePathEffect(inkex.EffectExtension):
def __init__(self): def add_arguments(self, pars):
inkex.Effect.__init__(self) pars.add_argument('--maxLength', type = float, default = '10', help = 'Maximum Length of New Segments')
self.arg_parser.add_argument('--maxLength', type = float, default = '10', help = 'Maximum Length of New Segments') pars.add_argument('--unit', default = 'mm', help = 'Unit of Measurement')
self.arg_parser.add_argument('--unit', default = 'mm', help = 'Unit of Measurement') pars.add_argument('--precision', type = int, default = '5', help = 'Number of significant digits')
self.arg_parser.add_argument('--precision', type = int, default = '5', help = 'Number of significant digits') pars.add_argument("--tab", default="sampling", help="Tab")
self.arg_parser.add_argument("--tab", default="sampling", help="Tab") pars.add_argument("--separateSegs", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--separateSegs", type=inkex.Boolean, default=True)
def effect(self): def effect(self):

View File

@ -56,11 +56,11 @@ def SVG_curve2(p1, c11, c12, p2, c21, c22, t):
def SVG_close(): def SVG_close():
return 'Z\n' return 'Z\n'
class Sprockets(inkex.Effect): class Sprockets(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self) def add_arguments(self, pars):
self.arg_parser.add_argument("-t", "--teeth", type=int, default=24, help="Number of teeth") pars.add_argument("-t", "--teeth", type=int, default=24, help="Number of teeth")
self.arg_parser.add_argument("-s", "--size", default="ANSI #40", help="Chain size (common values ANSI #35, ANSI #40, ANSI #60)") pars.add_argument("-s", "--size", default="ANSI #40", help="Chain size (common values ANSI #35, ANSI #40, ANSI #60)")
def get_pitch(self, size): def get_pitch(self, size):
return self.svg.unittouu({ return self.svg.unittouu({

View File

@ -4,25 +4,24 @@ rr = random.randint(1,10)
import inkex import inkex
from lxml import etree from lxml import etree
class StreaksEffect(inkex.Effect): class StreaksEffect(inkex.EffectExtension):
def __init__(self):
# Call the base class constructor. def add_arguments(self, pars):
inkex.Effect.__init__(self) pars.add_argument('--blur', type = int, default = 2)
self.arg_parser.add_argument('--blur', type = int, default = 2) pars.add_argument('--linno', type = int, default = 50)
self.arg_parser.add_argument('--linno', type = int, default = 50) pars.add_argument('--xrand', type = inkex.Boolean, default = True)
self.arg_parser.add_argument('--xrand', type = inkex.Boolean, default = True) pars.add_argument('--pagep', type = inkex.Boolean, default = True)
self.arg_parser.add_argument('--pagep', type = inkex.Boolean, default = True) pars.add_argument('--cusx', type = int, default = 500)
self.arg_parser.add_argument('--cusx', type = int, default = 500) pars.add_argument('--cusy', type = int, default = 500)
self.arg_parser.add_argument('--cusy', type = int, default = 500) pars.add_argument('--segLen', type = int, default = 8)
self.arg_parser.add_argument('--segLen', type = int, default = 8) pars.add_argument('--yrand', type = inkex.Boolean, default = True)
self.arg_parser.add_argument('--yrand', type = inkex.Boolean, default = True) pars.add_argument('--dashp', type = inkex.Boolean, default = True)
self.arg_parser.add_argument('--dashp', type = inkex.Boolean, default = True) pars.add_argument('--blankp', type = inkex.Boolean, default = True)
self.arg_parser.add_argument('--blankp', type = inkex.Boolean, default = True) pars.add_argument('--dotp', type = inkex.Boolean, default = True)
self.arg_parser.add_argument('--dotp', type = inkex.Boolean, default = True) pars.add_argument('--dots', type = int, default = 100)
self.arg_parser.add_argument('--dots', type = int, default = 100) pars.add_argument('--strokeColour', default = 255)
self.arg_parser.add_argument('--strokeColour', default = 255) pars.add_argument('--strokeWidth', type = int, default = 2)
self.arg_parser.add_argument('--strokeWidth', type = int, default = 2) pars.add_argument("--Nmain", default='title')
self.arg_parser.add_argument("--Nmain", default='title')
def effect(self): def effect(self):
blur = int(self.options.blur) blur = int(self.options.blur)

View File

@ -165,11 +165,11 @@ def stripline(bone,linewidth,logname):
fp.close() fp.close()
return outVertexArray return outVertexArray
class StripLineEffect(inkex.Effect): class StripLineEffect(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self) def add_arguments(self, pars):
self.arg_parser.add_argument("--linewidth", type=int, default="10", help="Line thickness") pars.add_argument("--linewidth", type=int, default="10", help="Line thickness")
self.arg_parser.add_argument("--logfilename", default="10", help="Log file name") pars.add_argument("--logfilename", default="10", help="Log file name")
def effect(self): def effect(self):
linewidth=self.options.linewidth linewidth=self.options.linewidth

View File

@ -32,15 +32,15 @@ import re
from lxml import etree from lxml import etree
class StrokeColorAsFill(inkex.EffectExtension): class StrokeColorAsFill(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self) def add_arguments(self, pars):
self.arg_parser.add_argument("--tab", help="The selected UI-tab") pars.add_argument("--tab", help="The selected UI-tab")
self.arg_parser.add_argument("--fill_stroke_mode", default="fillstroke", help="Exchange mode fill, stroke") pars.add_argument("--fill_stroke_mode", default="fillstroke", help="Exchange mode fill, stroke")
self.arg_parser.add_argument("--fill_stroke_copy_alpha", type=inkex.Boolean, default=True, help="Copy alpha") pars.add_argument("--fill_stroke_copy_alpha", type=inkex.Boolean, default=True, help="Copy alpha")
self.arg_parser.add_argument("--fill_stroke_copy_none", type=inkex.Boolean, default=True, help="Copy 'None' property") pars.add_argument("--fill_stroke_copy_none", type=inkex.Boolean, default=True, help="Copy 'None' property")
self.arg_parser.add_argument("--fill_stroke_copy_unset", type=inkex.Boolean, default=True, help="Copy 'Unset' property") pars.add_argument("--fill_stroke_copy_unset", type=inkex.Boolean, default=True, help="Copy 'Unset' property")
self.arg_parser.add_argument("--fill_stroke_convert_unset", type=inkex.Boolean, default=True, help="Convert 'Unset' property") pars.add_argument("--fill_stroke_convert_unset", type=inkex.Boolean, default=True, help="Convert 'Unset' property")
self.arg_parser.add_argument("--nodash", type=inkex.Boolean, default="false", help="Fix dash-stroke to alow no line only markers") pars.add_argument("--nodash", type=inkex.Boolean, default="false", help="Fix dash-stroke to alow no line only markers")
def color_swapper(self, element): def color_swapper(self, element):
if element.tag == inkex.addNS('g', 'svg'): if element.tag == inkex.addNS('g', 'svg'):

View File

@ -39,16 +39,15 @@ class StylesToLayers(inkex.EffectExtension):
layer.set(inkex.addNS('groupmode', 'inkscape'), 'layer') layer.set(inkex.addNS('groupmode', 'inkscape'), 'layer')
return layer return layer
def __init__(self): def add_arguments(self, pars):
inkex.EffectExtension.__init__(self) pars.add_argument("--apply_transformations", type=inkex.Boolean, default=False, help="Run 'Apply Transformations' extension before running vpype. Helps avoiding geometry shifting")
self.arg_parser.add_argument("--apply_transformations", type=inkex.Boolean, default=False, help="Run 'Apply Transformations' extension before running vpype. Helps avoiding geometry shifting") pars.add_argument("--separateby", default = "stroke", help = "Separate by")
self.arg_parser.add_argument("--separateby", default = "stroke", help = "Separate by") pars.add_argument("--parsecolors",default = "hexval", help = "Sort colors by")
self.arg_parser.add_argument("--parsecolors",default = "hexval", help = "Sort colors by") pars.add_argument("--subdividethreshold", type=int, default = 1, help = "Threshold for splitting into sub layers")
self.arg_parser.add_argument("--subdividethreshold", type=int, default = 1, help = "Threshold for splitting into sub layers") pars.add_argument("--decimals", type=int, default = 1, help = "Decimal tolerance")
self.arg_parser.add_argument("--decimals", type=int, default = 1, help = "Decimal tolerance") pars.add_argument("--cleanup", type=inkex.Boolean, default = True, help = "Decimal tolerance")
self.arg_parser.add_argument("--cleanup", type=inkex.Boolean, default = True, help = "Decimal tolerance") pars.add_argument("--put_unfiltered", type=inkex.Boolean, default = False, help = "Put unfiltered elements to a separate layer")
self.arg_parser.add_argument("--put_unfiltered", type=inkex.Boolean, default = False, help = "Put unfiltered elements to a separate layer") pars.add_argument("--show_info", type=inkex.Boolean, default = False, help = "Show elements which have no style attributes to filter")
self.arg_parser.add_argument("--show_info", type=inkex.Boolean, default = False, help = "Show elements which have no style attributes to filter")
def effect(self): def effect(self):