updated some default code

This commit is contained in:
Mario Voigt 2021-04-16 14:41:12 +02:00
parent e2dd99587c
commit 9356b657e4
34 changed files with 661 additions and 688 deletions

View File

@ -23,17 +23,13 @@ def draw_SVG_circle(parent, r, cx, cy, name):
class Gasket(inkex.EffectExtension): # choose a better name
def __init__(self):
" define how the options are mapped from the inx file "
inkex.Effect.__init__(self) # initialize the super class
# list of parameters defined in the .inx file
self.arg_parser.add_argument("--depth",type=int, default=3, help="command line help")
self.arg_parser.add_argument("--c1", type=float, default=2.0, help="command line help")
self.arg_parser.add_argument("--c2", type=float, default=3.0, help="command line help")
self.arg_parser.add_argument("--c3", type=float, default=3.0, help="command line help")
self.arg_parser.add_argument("--shrink", type=inkex.Boolean, default=True, help="command line help")
self.arg_parser.add_argument("--active_tab", default='title', help="Active tab.")
def add_arguments(self, pars):
pars.add_argument("--depth",type=int, default=3, help="command line help")
pars.add_argument("--c1", type=float, default=2.0, help="command line help")
pars.add_argument("--c2", type=float, default=3.0, help="command line help")
pars.add_argument("--c3", type=float, default=3.0, help="command line help")
pars.add_argument("--shrink", type=inkex.Boolean, default=True, help="command line help")
pars.add_argument("--active_tab", default='title', help="Active tab.")
def calc_unit_factor(self):
unit_factor = self.svg.unittouu(str(1.0) + self.options.units)

View File

@ -70,7 +70,7 @@ class Vector:
self.theta = _theta
class CircularGround(inkex.Effect):
class CircularGround(inkex.EffectExtension):
def unitToUu(self,param):
""" Convert units.
@ -387,17 +387,16 @@ class CircularGround(inkex.Effect):
_pts.append([p[0]-min_x,p[1]-min_y])
self.line(_pts)
def __init__(self):
inkex.Effect.__init__(self)
self.arg_parser.add_argument('--file')
self.arg_parser.add_argument('--angle', type=int)
self.arg_parser.add_argument('--cols', type=int)
self.arg_parser.add_argument('--diameter', type=float)
self.arg_parser.add_argument('--diamunits')
self.arg_parser.add_argument('--rows', type=int)
self.arg_parser.add_argument('--linewidth', type=float)
self.arg_parser.add_argument('--lineunits')
self.arg_parser.add_argument('--linecolor', type=inkex.Color)
def add_arguments(self, pars):
pars.add_argument('--file')
pars.add_argument('--angle', type=int)
pars.add_argument('--cols', type=int)
pars.add_argument('--diameter', type=float)
pars.add_argument('--diamunits')
pars.add_argument('--rows', type=int)
pars.add_argument('--linewidth', type=float)
pars.add_argument('--lineunits')
pars.add_argument('--linecolor', type=inkex.Color)
def effect(self):
## Load the file

View File

@ -31,7 +31,7 @@ __author__ = 'Veronika Irvine'
__credits__ = ['Ben Connors', 'Veronika Irvine', 'Mark Shafer']
__license__ = 'Simplified BSD'
class LaceGrid(inkex.Effect):
class LaceGrid(inkex.EffectExtension):
def circle(self, x, y, r, fill):
# define the stroke style
s = {'fill': fill}
@ -70,17 +70,16 @@ class LaceGrid(inkex.Effect):
y += vgrid;
def __init__(self):
inkex.Effect.__init__(self)
self.arg_parser.add_argument('--angle', type=float)
self.arg_parser.add_argument('--distance', type=float)
self.arg_parser.add_argument('--pinunits')
self.arg_parser.add_argument('--width', type=float)
self.arg_parser.add_argument('--patchunits')
self.arg_parser.add_argument('--height', type=float)
self.arg_parser.add_argument('--dotwidth', type=float)
self.arg_parser.add_argument('--dotunits')
self.arg_parser.add_argument('--dotcolor', type=inkex.Color)
def add_arguments(self, pars):
pars.add_argument('--angle', type=float)
pars.add_argument('--distance', type=float)
pars.add_argument('--pinunits')
pars.add_argument('--width', type=float)
pars.add_argument('--patchunits')
pars.add_argument('--height', type=float)
pars.add_argument('--dotwidth', type=float)
pars.add_argument('--dotunits')
pars.add_argument('--dotcolor', type=inkex.Color)
def effect(self):
"""

View File

@ -31,7 +31,8 @@ __author__ = 'Veronika Irvine'
__credits__ = ['Ben Connors', 'Veronika Irvine', 'Mark Shafer']
__license__ = 'Simplified BSD'
class LaceGround(inkex.Effect):
class LaceGround(inkex.EffectExtesnsion):
def loadFile(self):
# Ensure that file exists and has the proper extension
if not self.options.file:
@ -134,18 +135,17 @@ class LaceGround(inkex.Effect):
repeatY += 1
y += deltaY * rowCount
def __init__(self):
inkex.Effect.__init__(self)
self.arg_parser.add_argument('-f', '--file', help='File containing lace ground description')
self.arg_parser.add_argument('--angle', type=float)
self.arg_parser.add_argument('--distance', type=float)
self.arg_parser.add_argument('--pinunits')
self.arg_parser.add_argument('--width', type=float)
self.arg_parser.add_argument('--patchunits')
self.arg_parser.add_argument('--height', type=float)
self.arg_parser.add_argument('--linewidth', type=float)
self.arg_parser.add_argument('--lineunits')
self.arg_parser.add_argument('--linecolor', type=inkex.Color)
def add_arguments(self, pars):
pars.add_argument('-f', '--file', help='File containing lace ground description')
pars.add_argument('--angle', type=float)
pars.add_argument('--distance', type=float)
pars.add_argument('--pinunits')
pars.add_argument('--width', type=float)
pars.add_argument('--patchunits')
pars.add_argument('--height', type=float)
pars.add_argument('--linewidth', type=float)
pars.add_argument('--lineunits')
pars.add_argument('--linecolor', type=inkex.Color)
def effect(self):
result = self.loadFile()

View File

@ -25,19 +25,19 @@ __author__ = 'Jo Pol'
__credits__ = ['Veronika Irvine','Jo Pol','Mark Shafer']
__license__ = 'GPLv3'
class PolarGrid(inkex.Effect):
def __init__(self):
inkex.Effect.__init__(self)
self.arg_parser.add_argument('-a', '--angle', type=float, default=45, help='grid angle (degrees)')
self.arg_parser.add_argument('-d', '--dots', type=int, default=180, help='number of dots on a circle')
self.arg_parser.add_argument('-o', '--outerDiameter', type=float, default=160, help='outer diameter (mm)')
self.arg_parser.add_argument('-i', '--innerDiameter', type=float, default=100, help='minimum inner diameter (mm)')
self.arg_parser.add_argument('-f', '--fill', type=inkex.Color, default='-6711040', help='dot color')
self.arg_parser.add_argument('-A', '--alignment', default='outside', help='exact diameter on [inside|outside]')
self.arg_parser.add_argument('-s', '--size', type=float, default=0.5, help='dot diameter (mm)')
self.arg_parser.add_argument('-v', '--variant', default='', help='omit rows to get [|rectangle|hexagon1]')
self.arg_parser.add_argument('-cu', '--circleDiameterUnits', default = 'mm', help = 'Circle diameter is measured in these units')
self.arg_parser.add_argument('-du', '--dotUnits', default = 'px', help = 'Dot diameter is measured in these unites')
class PolarGrid(inkex.EffectExtension):
def add_arguments(self, pars):
pars.add_argument('-a', '--angle', type=float, default=45, help='grid angle (degrees)')
pars.add_argument('-d', '--dots', type=int, default=180, help='number of dots on a circle')
pars.add_argument('-o', '--outerDiameter', type=float, default=160, help='outer diameter (mm)')
pars.add_argument('-i', '--innerDiameter', type=float, default=100, help='minimum inner diameter (mm)')
pars.add_argument('-f', '--fill', type=inkex.Color, default='-6711040', help='dot color')
pars.add_argument('-A', '--alignment', default='outside', help='exact diameter on [inside|outside]')
pars.add_argument('-s', '--size', type=float, default=0.5, help='dot diameter (mm)')
pars.add_argument('-v', '--variant', default='', help='omit rows to get [|rectangle|hexagon1]')
pars.add_argument('-cu', '--circleDiameterUnits', default = 'mm', help = 'Circle diameter is measured in these units')
pars.add_argument('-du', '--dotUnits', default = 'px', help = 'Dot diameter is measured in these unites')
def group(self, diameter):
"""

View File

@ -260,38 +260,36 @@ def side(group,root,startOffset,endOffset,tabVec,length,direction,isTab,isDivide
return s
class BoxMaker(inkex.Effect):
def __init__(self):
# Call the base class constructor.
inkex.Effect.__init__(self)
# Define options
self.arg_parser.add_argument('--schroff',type=int,default=0,help='Enable Schroff mode')
self.arg_parser.add_argument('--rail_height',type=float,default=10.0,help='Height of rail')
self.arg_parser.add_argument('--rail_mount_depth',type=float,default=17.4,help='Depth at which to place hole for rail mount bolt')
self.arg_parser.add_argument('--rail_mount_centre_offset',type=float, default=0.0,help='How far toward row centreline to offset rail mount bolt (from rail centreline)')
self.arg_parser.add_argument('--rows',type=int,default=0,help='Number of Schroff rows')
self.arg_parser.add_argument('--hp',type=int,default=0,help='Width (TE/HP units) of Schroff rows')
self.arg_parser.add_argument('--row_spacing',type=float,default=10.0,help='Height of rail')
self.arg_parser.add_argument('--unit', default='mm',help='Measure Units')
self.arg_parser.add_argument('--inside',type=int,default=0,help='Int/Ext Dimension')
self.arg_parser.add_argument('--length',type=float,default=100,help='Length of Box')
self.arg_parser.add_argument('--width',type=float,default=100,help='Width of Box')
self.arg_parser.add_argument('--depth',type=float,default=100,help='Height of Box')
self.arg_parser.add_argument('--tab',type=float,default=25,help='Nominal Tab Width')
self.arg_parser.add_argument('--equal',type=int,default=0,help='Equal/Prop Tabs')
self.arg_parser.add_argument('--tabsymmetry',type=int,default=0,help='Tab style')
self.arg_parser.add_argument('--dimpleheight',type=float,default=0,help='Tab Dimple Height')
self.arg_parser.add_argument('--dimplelength',type=float,default=0,help='Tab Dimple Tip Length')
self.arg_parser.add_argument('--hairline',type=int,default=0,help='Line Thickness')
self.arg_parser.add_argument('--thickness',type=float,default=10,help='Thickness of Material')
self.arg_parser.add_argument('--kerf',type=float,default=0.5,help='Kerf (width) of cut')
self.arg_parser.add_argument('--clearance',type=float,default=0.01,help='Clearance of joints')
self.arg_parser.add_argument('--style',type=int,default=25,help='Layout/Style')
self.arg_parser.add_argument('--spacing',type=float,default=25,help='Part Spacing')
self.arg_parser.add_argument('--boxtype',type=int,default=25,help='Box type')
self.arg_parser.add_argument('--div_l',type=int,default=25,help='Dividers (Length axis)')
self.arg_parser.add_argument('--div_w',type=int,default=25,help='Dividers (Width axis)')
self.arg_parser.add_argument('--keydiv',type=int,default=3,help='Key dividers into walls/floor')
class BoxMaker(inkex.EffectExtension):
def add_arguments(self, pars):
pars.add_argument('--schroff',type=int,default=0,help='Enable Schroff mode')
pars.add_argument('--rail_height',type=float,default=10.0,help='Height of rail')
pars.add_argument('--rail_mount_depth',type=float,default=17.4,help='Depth at which to place hole for rail mount bolt')
pars.add_argument('--rail_mount_centre_offset',type=float, default=0.0,help='How far toward row centreline to offset rail mount bolt (from rail centreline)')
pars.add_argument('--rows',type=int,default=0,help='Number of Schroff rows')
pars.add_argument('--hp',type=int,default=0,help='Width (TE/HP units) of Schroff rows')
pars.add_argument('--row_spacing',type=float,default=10.0,help='Height of rail')
pars.add_argument('--unit', default='mm',help='Measure Units')
pars.add_argument('--inside',type=int,default=0,help='Int/Ext Dimension')
pars.add_argument('--length',type=float,default=100,help='Length of Box')
pars.add_argument('--width',type=float,default=100,help='Width of Box')
pars.add_argument('--depth',type=float,default=100,help='Height of Box')
pars.add_argument('--tab',type=float,default=25,help='Nominal Tab Width')
pars.add_argument('--equal',type=int,default=0,help='Equal/Prop Tabs')
pars.add_argument('--tabsymmetry',type=int,default=0,help='Tab style')
pars.add_argument('--dimpleheight',type=float,default=0,help='Tab Dimple Height')
pars.add_argument('--dimplelength',type=float,default=0,help='Tab Dimple Tip Length')
pars.add_argument('--hairline',type=int,default=0,help='Line Thickness')
pars.add_argument('--thickness',type=float,default=10,help='Thickness of Material')
pars.add_argument('--kerf',type=float,default=0.5,help='Kerf (width) of cut')
pars.add_argument('--clearance',type=float,default=0.01,help='Clearance of joints')
pars.add_argument('--style',type=int,default=25,help='Layout/Style')
pars.add_argument('--spacing',type=float,default=25,help='Part Spacing')
pars.add_argument('--boxtype',type=int,default=25,help='Box type')
pars.add_argument('--div_l',type=int,default=25,help='Dividers (Length axis)')
pars.add_argument('--div_w',type=int,default=25,help='Dividers (Width axis)')
pars.add_argument('--keydiv',type=int,default=3,help='Key dividers into walls/floor')
def effect(self):
global group,nomTab,equalTabs,tabSymmetry,dimpleHeight,dimpleLength,thickness,correction,divx,divy,hairline,linethickness,keydivwalls,keydivfloor

View File

@ -26,30 +26,29 @@ import inkex
from inkex.paths import Path, CubicSuperPath
from inkex import Style, Color, Circle
class ContourScanner(inkex.Effect):
class ContourScanner(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self)
self.arg_parser.add_argument("--main_tabs")
self.arg_parser.add_argument("--breakapart", type=inkex.Boolean, default=False, help="Break apart selection into single contours")
self.arg_parser.add_argument("--apply_transformations", type=inkex.Boolean, default=False, help="Run 'Apply Transformations' extension before running to avoid IndexErrors in calculation.")
self.arg_parser.add_argument("--removefillsetstroke", type=inkex.Boolean, default=False, help="Remove fill and define stroke")
self.arg_parser.add_argument("--strokewidth", type=float, default=1.0, help="Stroke width (px)")
self.arg_parser.add_argument("--highlight_opened", type=inkex.Boolean, default=True, help="Highlight opened contours")
self.arg_parser.add_argument("--color_opened", type=Color, default='4012452351', help="Color opened contours")
self.arg_parser.add_argument("--highlight_closed", type=inkex.Boolean, default=True, help="Highlight closed contours")
self.arg_parser.add_argument("--color_closed", type=Color, default='2330080511', help="Color closed contours")
self.arg_parser.add_argument("--highlight_selfintersecting", type=inkex.Boolean, default=True, help="Highlight self-intersecting contours")
self.arg_parser.add_argument("--highlight_intersectionpoints", type=inkex.Boolean, default=True, help="Highlight self-intersecting points")
self.arg_parser.add_argument("--color_selfintersecting", type=Color, default='1923076095', help="Color closed contours")
self.arg_parser.add_argument("--color_intersectionpoints", type=Color, default='4239343359', help="Color closed contours")
self.arg_parser.add_argument("--addlines", type=inkex.Boolean, default=True, help="Add closing lines for self-crossing contours")
self.arg_parser.add_argument("--polypaths", type=inkex.Boolean, default=True, help="Add polypath outline for self-crossing contours")
self.arg_parser.add_argument("--dotsize", type=int, default=10, help="Dot size (px) for self-intersecting points")
self.arg_parser.add_argument("--remove_opened", type=inkex.Boolean, default=False, help="Remove opened contours")
self.arg_parser.add_argument("--remove_closed", type=inkex.Boolean, default=False, help="Remove closed contours")
self.arg_parser.add_argument("--remove_selfintersecting", type=inkex.Boolean, default=False, help="Remove self-intersecting contours")
self.arg_parser.add_argument("--show_debug", type=inkex.Boolean, default=False, help="Show debug info")
def add_arguments(self, pars):
pars.add_argument("--main_tabs")
pars.add_argument("--breakapart", type=inkex.Boolean, default=False, help="Break apart selection into single contours")
pars.add_argument("--apply_transformations", type=inkex.Boolean, default=False, help="Run 'Apply Transformations' extension before running to avoid IndexErrors in calculation.")
pars.add_argument("--removefillsetstroke", type=inkex.Boolean, default=False, help="Remove fill and define stroke")
pars.add_argument("--strokewidth", type=float, default=1.0, help="Stroke width (px)")
pars.add_argument("--highlight_opened", type=inkex.Boolean, default=True, help="Highlight opened contours")
pars.add_argument("--color_opened", type=Color, default='4012452351', help="Color opened contours")
pars.add_argument("--highlight_closed", type=inkex.Boolean, default=True, help="Highlight closed contours")
pars.add_argument("--color_closed", type=Color, default='2330080511', help="Color closed contours")
pars.add_argument("--highlight_selfintersecting", type=inkex.Boolean, default=True, help="Highlight self-intersecting contours")
pars.add_argument("--highlight_intersectionpoints", type=inkex.Boolean, default=True, help="Highlight self-intersecting points")
pars.add_argument("--color_selfintersecting", type=Color, default='1923076095', help="Color closed contours")
pars.add_argument("--color_intersectionpoints", type=Color, default='4239343359', help="Color closed contours")
pars.add_argument("--addlines", type=inkex.Boolean, default=True, help="Add closing lines for self-crossing contours")
pars.add_argument("--polypaths", type=inkex.Boolean, default=True, help="Add polypath outline for self-crossing contours")
pars.add_argument("--dotsize", type=int, default=10, help="Dot size (px) for self-intersecting points")
pars.add_argument("--remove_opened", type=inkex.Boolean, default=False, help="Remove opened contours")
pars.add_argument("--remove_closed", type=inkex.Boolean, default=False, help="Remove closed contours")
pars.add_argument("--remove_selfintersecting", type=inkex.Boolean, default=False, help="Remove self-intersecting contours")
pars.add_argument("--show_debug", type=inkex.Boolean, default=False, help="Show debug info")
#function to refine the style of the lines
def adjustStyle(self, node):

View File

@ -58,14 +58,14 @@ class CutCraftNode(object):
return self.children[0].insert(part, shape)
class CutCraftShape(inkex.Effect):
def __init__(self):
inkex.Effect.__init__(self)
self.arg_parser.add_argument("--active-tab", default="Options", help="The tab selected when OK was pressed")
self.arg_parser.add_argument("--unit", default="mm", help="unit of measure for circular pitch and center diameter")
self.arg_parser.add_argument("--thickness", type=float, default=20.0, help="Material Thickness")
self.arg_parser.add_argument("--kerf", type=float, default=20.0, help="Laser Cutter Kerf")
self.arg_parser.add_argument("--linethickness", default="1px", help="Line Thickness")
class CutCraftShape(inkex.EffectExtension):
def add_arguments(self, pars):
pars.add_argument("--active-tab", default="Options", help="The tab selected when OK was pressed")
pars.add_argument("--unit", default="mm", help="unit of measure for circular pitch and center diameter")
pars.add_argument("--thickness", type=float, default=20.0, help="Material Thickness")
pars.add_argument("--kerf", type=float, default=20.0, help="Laser Cutter Kerf")
pars.add_argument("--linethickness", default="1px", help="Line Thickness")
def effect(self):
self.unit = self.options.unit

View File

@ -18,7 +18,7 @@ import sys
import os
from lxml import etree
class CutOptimWrapper(inkex.Effect):
class CutOptimWrapper(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self)
args = sys.argv[1:]

View File

@ -29,22 +29,22 @@ ToDos:
- maybe add some DXF model preview tool (maybe a useless idea at all)
"""
class PapercraftUnfold(inkex.Effect):
def __init__(self):
inkex.Effect.__init__(self)
self.arg_parser.add_argument("--inputfile")
self.arg_parser.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)
self.arg_parser.add_argument("--extraborder_units")
self.arg_parser.add_argument("--scalefactor", type=float, default=1.0, help="Manual scale factor")
self.arg_parser.add_argument("--nomerge", type=inkex.Boolean, default=False, help="No merging of faces into single polygon")
self.arg_parser.add_argument("--number", type=inkex.Boolean, default=False, help="Print face numbers (labels)")
self.arg_parser.add_argument("--divide", type=inkex.Boolean, default=False, help="Draw each face separate")
self.arg_parser.add_argument("--overlap", type=inkex.Boolean, default=False, help="Allow overlapping faces in cut-out sheet")
self.arg_parser.add_argument("--hide", type=inkex.Boolean, default=False, help="Hide glue tabs")
self.arg_parser.add_argument("--force", type=inkex.Boolean, default=False, help="Force glue tabs, even if intersecting faces")
self.arg_parser.add_argument("--split", default="", help="Comma separated list of face numbers to disconnect from the rest")
self.arg_parser.add_argument("--strategy", default=0, help="Generation strategy")
class PapercraftUnfold(inkex.EffectExtension):
def add_arguments(self, pars):
pars.add_argument("--inputfile")
pars.add_argument("--resizetoimport", type=inkex.Boolean, default=True, help="Resize the canvas to the imported drawing's bounding box")
pars.add_argument("--extraborder", type=float, default=0.0)
pars.add_argument("--extraborder_units")
pars.add_argument("--scalefactor", type=float, default=1.0, help="Manual scale factor")
pars.add_argument("--nomerge", type=inkex.Boolean, default=False, help="No merging of faces into single polygon")
pars.add_argument("--number", type=inkex.Boolean, default=False, help="Print face numbers (labels)")
pars.add_argument("--divide", type=inkex.Boolean, default=False, help="Draw each face separate")
pars.add_argument("--overlap", type=inkex.Boolean, default=False, help="Allow overlapping faces in cut-out sheet")
pars.add_argument("--hide", type=inkex.Boolean, default=False, help="Hide glue tabs")
pars.add_argument("--force", type=inkex.Boolean, default=False, help="Force glue tabs, even if intersecting faces")
pars.add_argument("--split", default="", help="Comma separated list of face numbers to disconnect from the rest")
pars.add_argument("--strategy", default=0, help="Generation strategy")
def effect(self):
dxf_input = self.options.inputfile

View File

@ -48,77 +48,77 @@ from ezdxf.addons.drawing.matplotlib import MatplotlibBackend #for recent ezdxf
from ezdxf.addons import Importer
class DXFDWGImport(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self)
def add_arguments(self, pars):
#blank tabs
self.arg_parser.add_argument("--tab")
pars.add_argument("--tab")
#general
self.arg_parser.add_argument("--inputfile")
self.arg_parser.add_argument("--dxf_to_svg_parser", default="bjnortier", help="Choose a DXF to SVG parser")
self.arg_parser.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)
self.arg_parser.add_argument("--extraborder_units")
pars.add_argument("--inputfile")
pars.add_argument("--dxf_to_svg_parser", default="bjnortier", help="Choose a DXF to SVG parser")
pars.add_argument("--resizetoimport", type=inkex.Boolean, default=True, help="Resize the canvas to the imported drawing's bounding box")
pars.add_argument("--extraborder", type=float, default=0.0)
pars.add_argument("--extraborder_units")
#ODA File Converter
self.arg_parser.add_argument("--oda_fileconverter", default=r"C:\Program Files\ODA\oda_fileconverter_title 21.6.0\oda_fileconverter.exe", help="Full path to 'oda_fileconverter.exe'")
self.arg_parser.add_argument("--oda_hidewindow", type=inkex.Boolean, default=True, help="Hide ODA GUI window")
self.arg_parser.add_argument("--oda_outputformat", default="ACAD2018_DXF", help="ODA AutoCAD Output version")
self.arg_parser.add_argument("--oda_keepconverted_dxf", type=inkex.Boolean, default=True, help="Keep ODA converted DXF file")
self.arg_parser.add_argument("--oda_skip_dxf_to_dxf", type=inkex.Boolean, default=False, help="Skip conversion from DXF to DXF")
self.arg_parser.add_argument("--oda_audit_repair", type=inkex.Boolean, default=True, help="Perform audit / autorepair")
pars.add_argument("--oda_fileconverter", default=r"C:\Program Files\ODA\oda_fileconverter_title 21.6.0\oda_fileconverter.exe", help="Full path to 'oda_fileconverter.exe'")
pars.add_argument("--oda_hidewindow", type=inkex.Boolean, default=True, help="Hide ODA GUI window")
pars.add_argument("--oda_outputformat", default="ACAD2018_DXF", help="ODA AutoCAD Output version")
pars.add_argument("--oda_keepconverted_dxf", type=inkex.Boolean, default=True, help="Keep ODA converted DXF file")
pars.add_argument("--oda_skip_dxf_to_dxf", type=inkex.Boolean, default=False, help="Skip conversion from DXF to DXF")
pars.add_argument("--oda_audit_repair", type=inkex.Boolean, default=True, help="Perform audit / autorepair")
#sk1 UniConvertor
self.arg_parser.add_argument("--sk1_uniconverter", default=r"C:\Program Files (x86)\sK1 Project\UniConvertor-1.1.6\uniconvertor.cmd", help="Full path to 'uniconvertor.cmd'")
self.arg_parser.add_argument("--opendironerror", type=inkex.Boolean, default=True, help="Open containing output directory on conversion errors")
pars.add_argument("--sk1_uniconverter", default=r"C:\Program Files (x86)\sK1 Project\UniConvertor-1.1.6\uniconvertor.cmd", help="Full path to 'uniconvertor.cmd'")
pars.add_argument("--opendironerror", type=inkex.Boolean, default=True, help="Open containing output directory on conversion errors")
#ezdxf preprocessing
self.arg_parser.add_argument("--ezdxf_output_version", default="SAME", help="ezdxf output version")
self.arg_parser.add_argument("--ezdfx_keep_preprocessed", type=inkex.Boolean, default=True, help="Keep ezdxf preprocessed DXF file")
self.arg_parser.add_argument("--ezdxf_preprocessing", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--allentities", type=inkex.Boolean, default=True)
pars.add_argument("--ezdxf_output_version", default="SAME", help="ezdxf output version")
pars.add_argument("--ezdfx_keep_preprocessed", type=inkex.Boolean, default=True, help="Keep ezdxf preprocessed DXF file")
pars.add_argument("--ezdxf_preprocessing", type=inkex.Boolean, default=True)
pars.add_argument("--allentities", type=inkex.Boolean, default=True)
#vpype-dxf (dread)
self.arg_parser.add_argument("--vpype_quantization", type=float, default=0.1, help="Maximum length of segments approximating curved elements (default 0.1mm)")
self.arg_parser.add_argument("--vpype_simplify", type=inkex.Boolean, default=False, help="Simplify curved elements")
self.arg_parser.add_argument("--vpype_parallel", type=inkex.Boolean, default=False, help="Multiprocessing curve conversion")
pars.add_argument("--vpype_quantization", type=float, default=0.1, help="Maximum length of segments approximating curved elements (default 0.1mm)")
pars.add_argument("--vpype_simplify", type=inkex.Boolean, default=False, help="Simplify curved elements")
pars.add_argument("--vpype_parallel", type=inkex.Boolean, default=False, help="Multiprocessing curve conversion")
#sk1 compatible entities
self.arg_parser.add_argument("--THREE_DFACE", type=inkex.Boolean, default=True) #3DFACE
self.arg_parser.add_argument("--ARC", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--BLOCK", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--CIRCLE", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--ELLIPSE", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--LINE", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--LWPOLYLINE", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--POINT", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--POLYLINE", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--POP_TRAFO", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--SEQEND", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--SOLID", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--SPLINE", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--TABLE", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--VERTEX", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--VIEWPORT", type=inkex.Boolean, default=True)
pars.add_argument("--THREE_DFACE", type=inkex.Boolean, default=True) #3DFACE
pars.add_argument("--ARC", type=inkex.Boolean, default=True)
pars.add_argument("--BLOCK", type=inkex.Boolean, default=True)
pars.add_argument("--CIRCLE", type=inkex.Boolean, default=True)
pars.add_argument("--ELLIPSE", type=inkex.Boolean, default=True)
pars.add_argument("--LINE", type=inkex.Boolean, default=True)
pars.add_argument("--LWPOLYLINE", type=inkex.Boolean, default=True)
pars.add_argument("--POINT", type=inkex.Boolean, default=True)
pars.add_argument("--POLYLINE", type=inkex.Boolean, default=True)
pars.add_argument("--POP_TRAFO", type=inkex.Boolean, default=True)
pars.add_argument("--SEQEND", type=inkex.Boolean, default=True)
pars.add_argument("--SOLID", type=inkex.Boolean, default=True)
pars.add_argument("--SPLINE", type=inkex.Boolean, default=True)
pars.add_argument("--TABLE", type=inkex.Boolean, default=True)
pars.add_argument("--VERTEX", type=inkex.Boolean, default=True)
pars.add_argument("--VIEWPORT", type=inkex.Boolean, default=True)
#other entities
self.arg_parser.add_argument("--THREE_DSOLID", type=inkex.Boolean, default=True) #3DSOLID
self.arg_parser.add_argument("--ATTRIB", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--BODY", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--ARC_DIMENSION", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--HATCH", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--IMAGE", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--INSERT", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--MESH", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--MTEXT", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--RAY", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--REGION", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--SHAPE", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--SURFACE", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--TRACE", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--UNDERLAY", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--XLINE", type=inkex.Boolean, default=True)
pars.add_argument("--THREE_DSOLID", type=inkex.Boolean, default=True) #3DSOLID
pars.add_argument("--ATTRIB", type=inkex.Boolean, default=True)
pars.add_argument("--BODY", type=inkex.Boolean, default=True)
pars.add_argument("--ARC_DIMENSION", type=inkex.Boolean, default=True)
pars.add_argument("--HATCH", type=inkex.Boolean, default=True)
pars.add_argument("--IMAGE", type=inkex.Boolean, default=True)
pars.add_argument("--INSERT", type=inkex.Boolean, default=True)
pars.add_argument("--MESH", type=inkex.Boolean, default=True)
pars.add_argument("--MTEXT", type=inkex.Boolean, default=True)
pars.add_argument("--RAY", type=inkex.Boolean, default=True)
pars.add_argument("--REGION", type=inkex.Boolean, default=True)
pars.add_argument("--SHAPE", type=inkex.Boolean, default=True)
pars.add_argument("--SURFACE", type=inkex.Boolean, default=True)
pars.add_argument("--TRACE", type=inkex.Boolean, default=True)
pars.add_argument("--UNDERLAY", type=inkex.Boolean, default=True)
pars.add_argument("--XLINE", type=inkex.Boolean, default=True)
def openExplorer(self, temp_output_dir):
DETACHED_PROCESS = 0x00000008

View File

@ -72,51 +72,49 @@ def draw_circle_marker(x,y, radius, parent):
###
class Fret_ruler(inkex.Effect):
class Fret_ruler(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self)
# main tab
self.arg_parser.add_argument('--method', default='12th Root of 2', help="Method to calculate scale")
self.arg_parser.add_argument('--draw_style', default='Ruler', help="How to draw the Ruler/NEck")
self.arg_parser.add_argument("--nth", type=int,default=12, help="For different number of notes in a scale")
self.arg_parser.add_argument('--scala_filename', default='12tet', help="Name of file in scales directory")
self.arg_parser.add_argument("--units", default="in", help="The units of entered dimensions")
self.arg_parser.add_argument("--length", type=float, default=25.5, help="Length of the Scale (and Ruler)")
self.arg_parser.add_argument("--width", type=float, default=1.5, help="Width of the Ruler (= Nut if drawing a neck)")
self.arg_parser.add_argument("--frets", type=int, default=18, help="number of frets on the scale")
def add_arguments(self, pars):
pars.add_argument('--method', default='12th Root of 2', help="Method to calculate scale")
pars.add_argument('--draw_style', default='Ruler', help="How to draw the Ruler/NEck")
pars.add_argument("--nth", type=int,default=12, help="For different number of notes in a scale")
pars.add_argument('--scala_filename', default='12tet', help="Name of file in scales directory")
pars.add_argument("--units", default="in", help="The units of entered dimensions")
pars.add_argument("--length", type=float, default=25.5, help="Length of the Scale (and Ruler)")
pars.add_argument("--width", type=float, default=1.5, help="Width of the Ruler (= Nut if drawing a neck)")
pars.add_argument("--frets", type=int, default=18, help="number of frets on the scale")
#
self.arg_parser.add_argument("--fanned", type=inkex.Boolean, default=False, help="Two scales on either side of the Neck")
self.arg_parser.add_argument("--basslength", type=float, default=25.5, help="Length of the Bass side Scale")
self.arg_parser.add_argument("--perpendicular", type=int, default=7, help="Fret number which is perpendicular to the Neck")
pars.add_argument("--fanned", type=inkex.Boolean, default=False, help="Two scales on either side of the Neck")
pars.add_argument("--basslength", type=float, default=25.5, help="Length of the Bass side Scale")
pars.add_argument("--perpendicular", type=int, default=7, help="Fret number which is perpendicular to the Neck")
#
self.arg_parser.add_argument("--linewidth", type=float, default=0.1, help="Width of drawn lines")
self.arg_parser.add_argument("--notch_width", type=float, default=0.125, help="Width of Fret notches on Router template")
self.arg_parser.add_argument("--annotate", type=inkex.Boolean, default=True, help="Annotate with Markers etc")
self.arg_parser.add_argument("--centerline", type=inkex.Boolean, default=True, help="Draw a centerline")
pars.add_argument("--linewidth", type=float, default=0.1, help="Width of drawn lines")
pars.add_argument("--notch_width", type=float, default=0.125, help="Width of Fret notches on Router template")
pars.add_argument("--annotate", type=inkex.Boolean, default=True, help="Annotate with Markers etc")
pars.add_argument("--centerline", type=inkex.Boolean, default=True, help="Draw a centerline")
# Neck
self.arg_parser.add_argument("--constant_width", type=inkex.Boolean, default=True, help="Use Bridge width as well to make Neck")
self.arg_parser.add_argument("--width_bridge", type=float, default=2.0, help="Width at the Bridge (drawing Neck not Ruler)")
self.arg_parser.add_argument("--show_markers", type=inkex.Boolean, default=False, help="Show Neck Marker Positions")
self.arg_parser.add_argument('--markers', default='3,5,7,10,12,12,15', help="List of frets to draw markers on")
pars.add_argument("--constant_width", type=inkex.Boolean, default=True, help="Use Bridge width as well to make Neck")
pars.add_argument("--width_bridge", type=float, default=2.0, help="Width at the Bridge (drawing Neck not Ruler)")
pars.add_argument("--show_markers", type=inkex.Boolean, default=False, help="Show Neck Marker Positions")
pars.add_argument('--markers', default='3,5,7,10,12,12,15', help="List of frets to draw markers on")
#
self.arg_parser.add_argument("--nutcomp", type=inkex.Boolean, default=False, help="Modify Nut position")
self.arg_parser.add_argument("--nutcomp_value", default="0.012in (0.30mm)", help="Preset (usual) Nut compensation values")
self.arg_parser.add_argument("--nutcomp_manual", type=float, default=0.014, help="Manual distance to move Nut closer to Bridge")
pars.add_argument("--nutcomp", type=inkex.Boolean, default=False, help="Modify Nut position")
pars.add_argument("--nutcomp_value", default="0.012in (0.30mm)", help="Preset (usual) Nut compensation values")
pars.add_argument("--nutcomp_manual", type=float, default=0.014, help="Manual distance to move Nut closer to Bridge")
#
self.arg_parser.add_argument("--show_curves", type=inkex.Boolean, default=False, help="Show a neck curvature ruler")
self.arg_parser.add_argument("--neck_radius", type=float, default=2.0, help="Radius of Neck curvature")
self.arg_parser.add_argument("--arc_length", type=float, default=2.0, help="Length of Arc")
self.arg_parser.add_argument("--block_mode", type=inkex.Boolean, default=False, help="Draw block or finger style")
self.arg_parser.add_argument("--arc_height", type=float, default=2.0, help="height of Arc")
self.arg_parser.add_argument("--string_spacing", type=float, default=2.0, help="Spacing between strings")
pars.add_argument("--show_curves", type=inkex.Boolean, default=False, help="Show a neck curvature ruler")
pars.add_argument("--neck_radius", type=float, default=2.0, help="Radius of Neck curvature")
pars.add_argument("--arc_length", type=float, default=2.0, help="Length of Arc")
pars.add_argument("--block_mode", type=inkex.Boolean, default=False, help="Draw block or finger style")
pars.add_argument("--arc_height", type=float, default=2.0, help="height of Arc")
pars.add_argument("--string_spacing", type=float, default=2.0, help="Spacing between strings")
#
self.arg_parser.add_argument("--filter_tones", type=inkex.Boolean, default=True, help="Only show Scala files with this many notes in a scale.")
self.arg_parser.add_argument("--scale", type=int, default=12, help="number of Notes in the scale")
self.arg_parser.add_argument("--filter_label", type=inkex.Boolean, default=True, help="Only show Scala files with this keyword in them.")
self.arg_parser.add_argument("--keywords", default="diatonic", help="Keywords to search for")
pars.add_argument("--filter_tones", type=inkex.Boolean, default=True, help="Only show Scala files with this many notes in a scale.")
pars.add_argument("--scale", type=int, default=12, help="number of Notes in the scale")
pars.add_argument("--filter_label", type=inkex.Boolean, default=True, help="Only show Scala files with this keyword in them.")
pars.add_argument("--keywords", default="diatonic", help="Keywords to search for")
# here so we can have tabs
self.arg_parser.add_argument("-t", "--active-tab", default='ruler', help="Active tab.")
pars.add_argument("-t", "--active-tab", default='ruler', help="Active tab.")
def filter_scala_files(self, parent):
""" Look in the scale directory for files.

View File

@ -12,15 +12,15 @@ from lxml import etree
from involute import *
class Gears(inkex.Effect):
def __init__(self):
inkex.Effect.__init__(self)
self.arg_parser.add_argument("--tab", default="Options", help="The tab selected when OK was pressed")
self.arg_parser.add_argument("-t", "--teeth", type=int, default=24, help="Number of teeth")
self.arg_parser.add_argument("-p", "--pressure_angle", type=float, default="20", help="Pressure angle")
self.arg_parser.add_argument("-y", "--size_type", type=int, default="1", help="Size type (1 = module (mm), 2 = pitch diameter (inches), 3 = diametral pitch (inches)")
self.arg_parser.add_argument("-s", "--size", type=float, default="5", help="Size")
self.arg_parser.add_argument("-o", "--orientation", type=int, default="1", help="Gear orientation")
class Gears(inkex.EffectExtension):
def add_arguments(self, pars):
pars.add_argument("--tab", default="Options", help="The tab selected when OK was pressed")
pars.add_argument("-t", "--teeth", type=int, default=24, help="Number of teeth")
pars.add_argument("-p", "--pressure_angle", type=float, default="20", help="Pressure angle")
pars.add_argument("-y", "--size_type", type=int, default="1", help="Size type (1 = module (mm), 2 = pitch diameter (inches), 3 = diametral pitch (inches)")
pars.add_argument("-s", "--size", type=float, default="5", help="Size")
pars.add_argument("-o", "--orientation", type=int, default="1", help="Gear orientation")
def effect(self):
Z = self.options.teeth

View File

@ -23,7 +23,7 @@ License: GNU GPL v3
Used version of imagetracerjs: https://github.com/jankovicsandras/imagetracerjs/commit/4d0f429efbb936db1a43db80815007a2cb113b34
"""
class Imagetracerjs (inkex.Effect):
class Imagetracerjs (inkex.EffectExtension):
def checkImagePath(self, node):
xlink = node.get('xlink:href')
@ -48,27 +48,26 @@ class Imagetracerjs (inkex.Effect):
if (os.path.isfile(path)):
return path
def __init__(self):
inkex.Effect.__init__(self)
self.arg_parser.add_argument("--tabs")
self.arg_parser.add_argument("--keeporiginal", type=inkex.Boolean, default=False, help="Keep original image on canvas")
self.arg_parser.add_argument("--ltres", type=float, default=1.0, help="Error treshold straight lines")
self.arg_parser.add_argument("--qtres", type=float, default=1.0, help="Error treshold quadratic splines")
self.arg_parser.add_argument("--pathomit", type=int, default=8, help="Noise reduction - discard edge node paths shorter than")
self.arg_parser.add_argument("--rightangleenhance", type=inkex.Boolean, default=True, help="Enhance right angle corners")
self.arg_parser.add_argument("--colorsampling", default="2",help="Color sampling")
self.arg_parser.add_argument("--numberofcolors", type=int, default=16, help="Number of colors to use on palette")
self.arg_parser.add_argument("--mincolorratio", type=int, default=0, help="Color randomization ratio")
self.arg_parser.add_argument("--colorquantcycles", type=int, default=3, help="Color quantization will be repeated this many times")
self.arg_parser.add_argument("--layering", default="0",help="Layering")
self.arg_parser.add_argument("--strokewidth", type=float, default=1.0, help="SVG stroke-width")
self.arg_parser.add_argument("--linefilter", type=inkex.Boolean, default=False, help="Noise reduction line filter")
#self.arg_parser.add_argument("--scale", type=float, default=1.0, help="Coordinate scale factor")
self.arg_parser.add_argument("--roundcoords", type=int, default=1, help="Decimal places for rounding")
self.arg_parser.add_argument("--viewbox", type=inkex.Boolean, default=False, help="Enable or disable SVG viewBox")
self.arg_parser.add_argument("--desc", type=inkex.Boolean, default=False, help="SVG descriptions")
self.arg_parser.add_argument("--blurradius", type=int, default=0, help="Selective Gaussian blur preprocessing")
self.arg_parser.add_argument("--blurdelta", type=float, default=20.0, help="RGBA delta treshold for selective Gaussian blur preprocessing")
def add_arguments(self, pars):
pars.add_argument("--tabs")
pars.add_argument("--keeporiginal", type=inkex.Boolean, default=False, help="Keep original image on canvas")
pars.add_argument("--ltres", type=float, default=1.0, help="Error treshold straight lines")
pars.add_argument("--qtres", type=float, default=1.0, help="Error treshold quadratic splines")
pars.add_argument("--pathomit", type=int, default=8, help="Noise reduction - discard edge node paths shorter than")
pars.add_argument("--rightangleenhance", type=inkex.Boolean, default=True, help="Enhance right angle corners")
pars.add_argument("--colorsampling", default="2",help="Color sampling")
pars.add_argument("--numberofcolors", type=int, default=16, help="Number of colors to use on palette")
pars.add_argument("--mincolorratio", type=int, default=0, help="Color randomization ratio")
pars.add_argument("--colorquantcycles", type=int, default=3, help="Color quantization will be repeated this many times")
pars.add_argument("--layering", default="0",help="Layering")
pars.add_argument("--strokewidth", type=float, default=1.0, help="SVG stroke-width")
pars.add_argument("--linefilter", type=inkex.Boolean, default=False, help="Noise reduction line filter")
#pars.add_argument("--scale", type=float, default=1.0, help="Coordinate scale factor")
pars.add_argument("--roundcoords", type=int, default=1, help="Decimal places for rounding")
pars.add_argument("--viewbox", type=inkex.Boolean, default=False, help="Enable or disable SVG viewBox")
pars.add_argument("--desc", type=inkex.Boolean, default=False, help="SVG descriptions")
pars.add_argument("--blurradius", type=int, default=0, help="Selective Gaussian blur preprocessing")
pars.add_argument("--blurdelta", type=float, default=20.0, help="RGBA delta treshold for selective Gaussian blur preprocessing")
def effect(self):

View File

@ -24,17 +24,14 @@ def points_to_svgd(p, close=False):
return svgd
class Recursive(inkex.Effect):
class Recursive(inkex.EffectExtension):
def __init__(self):
" define how the options are mapped from the inx file "
inkex.Effect.__init__(self) # initialize the super class
self.arg_parser.add_argument("--verti", type=int, default=20, help="Height")
self.arg_parser.add_argument("--horiz", type=int, default=20, help="Length")
self.arg_parser.add_argument("--size", type=float, default=10.0, help="Cell Size")
self.arg_parser.add_argument("--algo", default=1, help="Algorithm")
self.arg_parser.add_argument("--width", type=float, default=10.0, help="Line width")
def add_arguments(self, pars):
pars.add_argument("--verti", type=int, default=20, help="Height")
pars.add_argument("--horiz", type=int, default=20, help="Length")
pars.add_argument("--size", type=float, default=10.0, help="Cell Size")
pars.add_argument("--algo", default=1, help="Algorithm")
pars.add_argument("--width", type=float, default=10.0, help="Line width")
def effect(self):
# basic style

View File

@ -23,37 +23,37 @@ import math
import inkex
import mehr_plate
class mehr_box_maker(inkex.Effect):
def __init__(self):
inkex.Effect.__init__(self)
self.arg_parser.add_argument('--page',default='page_1')
self.arg_parser.add_argument('--unit',default='mm')
self.arg_parser.add_argument('--inside')
self.arg_parser.add_argument('--X_size',type=float,default='0.0')
self.arg_parser.add_argument('--Y_size',type=float,default='0.0')
self.arg_parser.add_argument('--Z_size',type=float,default='0.0')
self.arg_parser.add_argument('--tab_mode',default='number')
self.arg_parser.add_argument('--tab_size',type=float,default='0.0')
self.arg_parser.add_argument('--X_tabs',type=int,default='0')
self.arg_parser.add_argument('--Y_tabs',type=int,default='0')
self.arg_parser.add_argument('--Z_tabs',type=int,default='0')
self.arg_parser.add_argument('--d_top',type=inkex.Boolean,default=True)
self.arg_parser.add_argument('--d_bottom',type=inkex.Boolean,default=True)
self.arg_parser.add_argument('--d_left',type=inkex.Boolean,default=True)
self.arg_parser.add_argument('--d_right',type=inkex.Boolean,default=True)
self.arg_parser.add_argument('--d_front',type=inkex.Boolean,default=True)
self.arg_parser.add_argument('--d_back',type=inkex.Boolean,default=True)
self.arg_parser.add_argument('--thickness',type=float,default=4,help='Thickness of Material')
self.arg_parser.add_argument('--kerf',type=float,default=0.2)
self.arg_parser.add_argument('--spaceing',type=float,default=1)
self.arg_parser.add_argument('--X_compartments',type=int,default=1)
self.arg_parser.add_argument('--X_divisions')
self.arg_parser.add_argument('--X_mode')
self.arg_parser.add_argument('--X_fit',type=inkex.Boolean)
self.arg_parser.add_argument('--Y_compartments',type=int,default=1)
self.arg_parser.add_argument('--Y_divisions')
self.arg_parser.add_argument('--Y_mode')
self.arg_parser.add_argument('--Y_fit',type=inkex.Boolean)
class mehr_box_maker(inkex.EffectExtension):
def add_arguments(self, pars):
pars.add_argument('--page',default='page_1')
pars.add_argument('--unit',default='mm')
pars.add_argument('--inside')
pars.add_argument('--X_size',type=float,default='0.0')
pars.add_argument('--Y_size',type=float,default='0.0')
pars.add_argument('--Z_size',type=float,default='0.0')
pars.add_argument('--tab_mode',default='number')
pars.add_argument('--tab_size',type=float,default='0.0')
pars.add_argument('--X_tabs',type=int,default='0')
pars.add_argument('--Y_tabs',type=int,default='0')
pars.add_argument('--Z_tabs',type=int,default='0')
pars.add_argument('--d_top',type=inkex.Boolean,default=True)
pars.add_argument('--d_bottom',type=inkex.Boolean,default=True)
pars.add_argument('--d_left',type=inkex.Boolean,default=True)
pars.add_argument('--d_right',type=inkex.Boolean,default=True)
pars.add_argument('--d_front',type=inkex.Boolean,default=True)
pars.add_argument('--d_back',type=inkex.Boolean,default=True)
pars.add_argument('--thickness',type=float,default=4,help='Thickness of Material')
pars.add_argument('--kerf',type=float,default=0.2)
pars.add_argument('--spaceing',type=float,default=1)
pars.add_argument('--X_compartments',type=int,default=1)
pars.add_argument('--X_divisions')
pars.add_argument('--X_mode')
pars.add_argument('--X_fit',type=inkex.Boolean)
pars.add_argument('--Y_compartments',type=int,default=1)
pars.add_argument('--Y_divisions')
pars.add_argument('--Y_mode')
pars.add_argument('--Y_fit',type=inkex.Boolean)
def effect(self):
thickness=self.svg.unittouu(str(self.options.thickness)+self.options.unit)

View File

@ -77,30 +77,30 @@ Module licenses
"""
class Unfold(inkex.Effect):
def __init__(self):
inkex.Effect.__init__(self)
self.arg_parser.add_argument("--tab")
self.arg_parser.add_argument("--inputfile")
self.arg_parser.add_argument("--generatelabels", type=inkex.Boolean, default=True, help="Generate labels for edges")
self.arg_parser.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)
self.arg_parser.add_argument("--extraborder_units")
self.arg_parser.add_argument("--show_fstl", type=inkex.Boolean, default=True, help="Show converted (and fixed) STL in fstl Viewer")
self.arg_parser.add_argument("--exact", type=inkex.Boolean, default=True, help="Only check for perfectly matched edges")
self.arg_parser.add_argument("--nearby", type=inkex.Boolean, default=True, help="Find and connect nearby facets. Correct bad facets")
self.arg_parser.add_argument("--tolerance", type=float, default=0.0, help="Initial tolerance to use for nearby check")
self.arg_parser.add_argument("--iterations", type=int, default=1, help="Number of iterations for nearby check")
self.arg_parser.add_argument("--increment", type=float, default=0.0, help="Amount to increment tolerance after iteration")
self.arg_parser.add_argument("--remove_unconnected", type=inkex.Boolean, default=True, help="Remove facets that have 0 neighbors")
self.arg_parser.add_argument("--fill_holes", type=inkex.Boolean, default=True, help="Add facets to fill holes")
self.arg_parser.add_argument("--normal_directions", type=inkex.Boolean, default=True, help="Check and fix direction of normals (ie cw, ccw)")
self.arg_parser.add_argument("--reverse_all", type=inkex.Boolean, default=True, help="Reverse the directions of all facets and normals")
self.arg_parser.add_argument("--normal_values", type=inkex.Boolean, default=True, help="Check and fix normal values")
self.arg_parser.add_argument("--xy_mirror", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--yz_mirror", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--xz_mirror", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--scale", type=float, default=1.0)
class Unfold(inkex.EffectExtension):
def add_arguments(self, pars):
pars.add_argument("--tab")
pars.add_argument("--inputfile")
pars.add_argument("--generatelabels", type=inkex.Boolean, default=True, help="Generate labels for edges")
pars.add_argument("--resizetoimport", type=inkex.Boolean, default=True, help="Resize the canvas to the imported drawing's bounding box")
pars.add_argument("--extraborder", type=float, default=0.0)
pars.add_argument("--extraborder_units")
pars.add_argument("--show_fstl", type=inkex.Boolean, default=True, help="Show converted (and fixed) STL in fstl Viewer")
pars.add_argument("--exact", type=inkex.Boolean, default=True, help="Only check for perfectly matched edges")
pars.add_argument("--nearby", type=inkex.Boolean, default=True, help="Find and connect nearby facets. Correct bad facets")
pars.add_argument("--tolerance", type=float, default=0.0, help="Initial tolerance to use for nearby check")
pars.add_argument("--iterations", type=int, default=1, help="Number of iterations for nearby check")
pars.add_argument("--increment", type=float, default=0.0, help="Amount to increment tolerance after iteration")
pars.add_argument("--remove_unconnected", type=inkex.Boolean, default=True, help="Remove facets that have 0 neighbors")
pars.add_argument("--fill_holes", type=inkex.Boolean, default=True, help="Add facets to fill holes")
pars.add_argument("--normal_directions", type=inkex.Boolean, default=True, help="Check and fix direction of normals (ie cw, ccw)")
pars.add_argument("--reverse_all", type=inkex.Boolean, default=True, help="Reverse the directions of all facets and normals")
pars.add_argument("--normal_values", type=inkex.Boolean, default=True, help="Check and fix normal values")
pars.add_argument("--xy_mirror", type=inkex.Boolean, default=True)
pars.add_argument("--yz_mirror", type=inkex.Boolean, default=True)
pars.add_argument("--xz_mirror", type=inkex.Boolean, default=True)
pars.add_argument("--scale", type=float, default=1.0)
def effect(self):
inputfile = self.options.inputfile

View File

@ -189,19 +189,14 @@ def chunks(alist, max_len):
# ----- PathOps() class, methods
class PathOps(inkex.Effect):
"""Effect-based class to apply Inkscape path operations."""
class PathOps(inkex.EffectExtension):
def __init__(self):
"""Init base class."""
inkex.Effect.__init__(self)
# options
self.arg_parser.add_argument("--ink_verb", default="SelectionDiff", help="Inkscape verb for path op")
self.arg_parser.add_argument("--max_ops", type=int, default=500, help="Max ops per external run")
self.arg_parser.add_argument("--recursive_sel", type=inkex.Boolean, help="Recurse beyond one group level")
self.arg_parser.add_argument("--keep_top", type=inkex.Boolean, help="Keep top element when done")
self.arg_parser.add_argument("--dry_run", type=inkex.Boolean, default=False, help="Dry-run without exec")
def add_arguments(self, pars):
pars.add_argument("--ink_verb", default="SelectionDiff", help="Inkscape verb for path op")
pars.add_argument("--max_ops", type=int, default=500, help="Max ops per external run")
pars.add_argument("--recursive_sel", type=inkex.Boolean, help="Recurse beyond one group level")
pars.add_argument("--keep_top", type=inkex.Boolean, help="Keep top element when done")
pars.add_argument("--dry_run", type=inkex.Boolean, default=False, help="Dry-run without exec")
def get_selected_ids(self):
"""Return a list of valid ids for inkscape path operations."""

View File

@ -27,12 +27,12 @@ from math import *
from lxml import etree
def points_to_svgd(p):
f = p[0]
p = p[1:]
svgd = 'M%.3f,%.3f' % f
for x in p:
svgd += 'L%.3f,%.3f' % x
return svgd
f = p[0]
p = p[1:]
svgd = 'M%.3f,%.3f' % f
for x in p:
svgd += 'L%.3f,%.3f' % x
return svgd
# these are designed to be 100px wide - they have to be scaled
no_tab = { 'cut' : ['m 0,0 100,0'], 'perf' : []}
@ -41,188 +41,188 @@ notab = {0 : no_tab}
simpletab = {0: {'cut': ['m 0,0 20,19 60,0 l 20,-19'], 'perf' : ['m 0,0 100,0']}}
# tab array - 0 = slot/tab, 1 = two tabs, 2 = single tab (alternate tab and nothing), 3 = none
tabStyle = [{ \
50 : {'cut': ['m 0,0 35,0 0,2 -6,0 c 0,0 1,8 6,12 8,6 22,6 30,0 5,-4 6,-12 6,-12 l -6,0 0,-2 35,0'], 'perf' : ['M 42,0 58,0']}, \
24 : {'cut': ['m 0,0 55,0 0,2 -6,0 c 0,0 1,3 6,6 8,3 19,6 27,8 5,-4 9,-14 9,-14 l -6,0 0,-2 15,0'], 'perf' : ['M 62,0 78,0']}, \
18 : {'cut' : ['m 0,0 65,0 0,2 -6,0 c 0,0 1,3 6,6 8,2 11,2 19,3 5,-4 9,-10 7,-9 l -6,0 0,-2 15,0'], 'perf' : ['m 72,0 6,0']}, \
6 : {'cut': ['m 0,0 70,0 2,7 10,1 5,-6 -2,0 0,-2 15,0'], 'perf' : ['m 74,0 7,0']},
0 : { 'cut' : ['m 0,0 100,0'], 'perf' : []}}, simpletab, simpletab, notab]
50 : {'cut': ['m 0,0 35,0 0,2 -6,0 c 0,0 1,8 6,12 8,6 22,6 30,0 5,-4 6,-12 6,-12 l -6,0 0,-2 35,0'], 'perf' : ['M 42,0 58,0']}, \
24 : {'cut': ['m 0,0 55,0 0,2 -6,0 c 0,0 1,3 6,6 8,3 19,6 27,8 5,-4 9,-14 9,-14 l -6,0 0,-2 15,0'], 'perf' : ['M 62,0 78,0']}, \
18 : {'cut' : ['m 0,0 65,0 0,2 -6,0 c 0,0 1,3 6,6 8,2 11,2 19,3 5,-4 9,-10 7,-9 l -6,0 0,-2 15,0'], 'perf' : ['m 72,0 6,0']}, \
6 : {'cut': ['m 0,0 70,0 2,7 10,1 5,-6 -2,0 0,-2 15,0'], 'perf' : ['m 74,0 7,0']},
0 : { 'cut' : ['m 0,0 100,0'], 'perf' : []}}, simpletab, simpletab, notab]
slotStyle = [{\
50: {'cut': ['m 0,0 20,19 60,0 l 20,-19','m 28,-3 4,5 36,0 4,-5'], 'perf' : ['M 0,0 28,0','M 100,0 72,0']}, \
24 : {'cut': ['M 100,0 90,18 30,11 20,0 0,0', 'm 92,-3 -4,5 -36,0 -4,-5'], 'perf' : ['M 100,0 92,0', 'M 20,0 48,0']}, \
18 : {'cut' : ['M 100,0 90,16 40,9 35,0 0,0', 'm 92,-3 -4,5 -26,0 -4,-5'], 'perf' : ['M 100,0 92,0', 'M 35,0 58,0']}, \
6 : {'cut' : ['M 100,0 98,10 88,9 84,2 86,2 86,0 0,0'], 'perf' : ['m 96,0 -6,0']},
0 : { 'cut' : ['m 0,0 100,0'], 'perf' : [] }}, simpletab, notab, notab]
50: {'cut': ['m 0,0 20,19 60,0 l 20,-19','m 28,-3 4,5 36,0 4,-5'], 'perf' : ['M 0,0 28,0','M 100,0 72,0']}, \
24 : {'cut': ['M 100,0 90,18 30,11 20,0 0,0', 'm 92,-3 -4,5 -36,0 -4,-5'], 'perf' : ['M 100,0 92,0', 'M 20,0 48,0']}, \
18 : {'cut' : ['M 100,0 90,16 40,9 35,0 0,0', 'm 92,-3 -4,5 -26,0 -4,-5'], 'perf' : ['M 100,0 92,0', 'M 35,0 58,0']}, \
6 : {'cut' : ['M 100,0 98,10 88,9 84,2 86,2 86,0 0,0'], 'perf' : ['m 96,0 -6,0']},
0 : { 'cut' : ['m 0,0 100,0'], 'perf' : [] }}, simpletab, notab, notab]
class Polyhedra(inkex.Effect):
def __init__(self):
inkex.Effect.__init__(self)
self.arg_parser.add_argument("-p", "--poly", default='Cube', help="polygon net to render")
self.arg_parser.add_argument("-s", "--size", type=float, default=100.0, help="size of first edge, in px")
self.arg_parser.add_argument("-t", "--tabs", type=int, default=0, help="tab style")
class Polyhedra(inkex.EffectExtension):
def get_tab(self, limitAngle):
return(self.get_connector('tab', limitAngle))
def add_arguments(self, pars):
pars.add_argument("-p", "--poly", default='Cube', help="polygon net to render")
pars.add_argument("-s", "--size", type=float, default=100.0, help="size of first edge, in px")
pars.add_argument("-t", "--tabs", type=int, default=0, help="tab style")
def get_slot(self, limitAngle):
return(self.get_connector('slot', limitAngle))
def get_tab(self, limitAngle):
return(self.get_connector('tab', limitAngle))
def get_connector(self, type, limitAngle):
if(self.options.tabs == 1): # two tabs
return(self.gen_tab(limitAngle/2))
def get_slot(self, limitAngle):
return(self.get_connector('slot', limitAngle))
if(self.options.tabs == 2): # one tab
if(type == 'tab'):
return(self.gen_tab(limitAngle))
else:
return(no_tab)
def get_connector(self, type, limitAngle):
if(self.options.tabs == 1): # two tabs
return(self.gen_tab(limitAngle/2))
if(self.options.tabs == 3): # no tabs or slots
return(no_tab)
if(self.options.tabs == 2): # one tab
if(type == 'tab'):
return(self.gen_tab(limitAngle))
else:
return(no_tab)
# otherwise, get stuff from the array of specially modified tab/slots
if(self.options.tabs == 3): # no tabs or slots
return(no_tab)
if(type == 'tab'):
source = tabStyle
else:
source = slotStyle
# otherwise, get stuff from the array of specially modified tab/slots
cuttable = source[self.options.tabs].keys()
sorted(cuttable) # sorts in-place. Ugh.
reversed(cuttable) # in-place. Ugh.
for angle in cuttable:
if(limitAngle >= angle):
return(source[self.options.tabs][angle])
if(type == 'tab'):
source = tabStyle
else:
source = slotStyle
def gen_tab(self, theta_degrees):
theta = radians(min(theta_degrees,90))
minOffset = 8
tabAngle = radians(40)
minTabLength = 40
tabHeight = 19 # must be >= minOffset
tabWidth = 100
cuttable = source[self.options.tabs].keys()
sorted(cuttable) # sorts in-place. Ugh.
reversed(cuttable) # in-place. Ugh.
for angle in cuttable:
if(limitAngle >= angle):
return(source[self.options.tabs][angle])
# determine if we need to sqash down side of tab by limit angle
bX = minOffset * cos(theta) / sin(theta)
aX = bX - (minOffset * cos(tabAngle) / sin(tabAngle))
if(theta >= tabAngle):
tab_cut = [(0,0), (tabHeight/sin(tabAngle) * cos(tabAngle), tabHeight)]
tab_perf = [(0,0), (tabWidth,0)]
else:
if (aX > (tabWidth - minTabLength)): # too stubby, don't put a tab
return(no_tab)
tab_cut = [(0,0), (aX,0), (bX, minOffset)]
tab_perf = [(aX,0), (tabWidth,0)]
def gen_tab(self, theta_degrees):
theta = radians(min(theta_degrees,90))
minOffset = 8
tabAngle = radians(40)
minTabLength = 40
tabHeight = 19 # must be >= minOffset
tabWidth = 100
# now see if we also have to squash the other side of the tab - this happens
# for very small angles where the tab height on the far side would still be
# too high and would intersect with the other tab
# determine if we need to sqash down side of tab by limit angle
bX = minOffset * cos(theta) / sin(theta)
aX = bX - (minOffset * cos(tabAngle) / sin(tabAngle))
if(theta >= tabAngle):
tab_cut = [(0,0), (tabHeight/sin(tabAngle) * cos(tabAngle), tabHeight)]
tab_perf = [(0,0), (tabWidth,0)]
else:
if (aX > (tabWidth - minTabLength)): # too stubby, don't put a tab
return(no_tab)
tab_cut = [(0,0), (aX,0), (bX, minOffset)]
tab_perf = [(aX,0), (tabWidth,0)]
# first, find where the tab would intersect the limit angle if we just put
# out a line of infinite length at the tab angle.
bmult = tabWidth / (cos(theta) * sin(tabAngle) / sin(theta) + cos(tabAngle))
tiY = bmult * sin(tabAngle)
# now see if we also have to squash the other side of the tab - this happens
# for very small angles where the tab height on the far side would still be
# too high and would intersect with the other tab
# now see if that intersection is too low. If so, limit the tab's height
tiY = min(tiY, tabHeight)
tab_cut.append((tabWidth - tiY / sin(tabAngle) * cos(tabAngle), tiY))
tab_cut.append((tabWidth, 0))
# first, find where the tab would intersect the limit angle if we just put
# out a line of infinite length at the tab angle.
bmult = tabWidth / (cos(theta) * sin(tabAngle) / sin(theta) + cos(tabAngle))
tiY = bmult * sin(tabAngle)
return({'cut' : [points_to_svgd(tab_cut)], 'perf' : [points_to_svgd(tab_perf)]})
# now see if that intersection is too low. If so, limit the tab's height
tiY = min(tiY, tabHeight)
tab_cut.append((tabWidth - tiY / sin(tabAngle) * cos(tabAngle), tiY))
tab_cut.append((tabWidth, 0))
def effect(self):
poly = self.options.poly
size = self.options.size
return({'cut' : [points_to_svgd(tab_cut)], 'perf' : [points_to_svgd(tab_perf)]})
eC = polyhedronData[poly]['edgeCoordinates']
iEI = polyhedronData[poly]['insideEdgeIndices']
oEI = polyhedronData[poly]['outsideEdgeIndices']
oED = polyhedronData[poly]['outsideEdgeDegrees']
sidelen = sqrt((eC[oEI[0][0]-1][0] - eC[oEI[0][1]-1][0])**2 + \
(eC[oEI[0][0]-1][1] - eC[oEI[0][1]-1][1])**2)
scale = size / sidelen
def effect(self):
poly = self.options.poly
size = self.options.size
# Translate group, Rotate path.
t = 'translate(' + str( self.svg.namedview.center[0] ) + ',' + str( self.svg.namedview.center[1] ) + ')'
g_attribs = {inkex.addNS('label','inkscape'):'Polygon ' + str( poly ), 'transform':t }
g = etree.SubElement(self.svg.get_current_layer(), 'g', g_attribs)
eC = polyhedronData[poly]['edgeCoordinates']
iEI = polyhedronData[poly]['insideEdgeIndices']
oEI = polyhedronData[poly]['outsideEdgeIndices']
oED = polyhedronData[poly]['outsideEdgeDegrees']
sidelen = sqrt((eC[oEI[0][0]-1][0] - eC[oEI[0][1]-1][0])**2 + \
(eC[oEI[0][0]-1][1] - eC[oEI[0][1]-1][1])**2)
scale = size / sidelen
gsub_attribs = {inkex.addNS('label','inkscape'):'Polygon ' + str( poly ) + 'border' }
gsub = etree.SubElement(g, 'g', gsub_attribs)
# Translate group, Rotate path.
t = 'translate(' + str( self.svg.namedview.center[0] ) + ',' + str( self.svg.namedview.center[1] ) + ')'
g_attribs = {inkex.addNS('label','inkscape'):'Polygon ' + str( poly ), 'transform':t }
g = etree.SubElement(self.svg.get_current_layer(), 'g', g_attribs)
# Create SVG Path for gear
cutStyle = { 'stroke': '#0000FF', 'fill': 'none' }
perfStyle = { 'stroke': '#FF0000', 'fill': 'none' }
textStyle = {
'font-size': str( size/4 ),
'font-family': 'arial',
'text-anchor': 'middle',
'text-align': 'center',
'fill': '#222'
}
gsub_attribs = {inkex.addNS('label','inkscape'):'Polygon ' + str( poly ) + 'border' }
gsub = etree.SubElement(g, 'g', gsub_attribs)
numOEI = len(oEI)
for edgeIndex in range(numOEI):
eX1 = eC[oEI[edgeIndex][0]-1][0]
eY1 = eC[oEI[edgeIndex][0]-1][1]
eX2 = eC[oEI[edgeIndex][1]-1][0]
eY2 = eC[oEI[edgeIndex][1]-1][1]
# Create SVG Path for gear
cutStyle = { 'stroke': '#0000FF', 'fill': 'none' }
perfStyle = { 'stroke': '#FF0000', 'fill': 'none' }
textStyle = {
'font-size': str( size/4 ),
'font-family': 'arial',
'text-anchor': 'middle',
'text-align': 'center',
'fill': '#222'
}
origin = (eX1 * scale, eY1 * scale)
edgelen = sqrt((eX1 - eX2)**2 + (eY1 - eY2)**2)
edgesize = size * (edgelen / sidelen)
numOEI = len(oEI)
for edgeIndex in range(numOEI):
eX1 = eC[oEI[edgeIndex][0]-1][0]
eY1 = eC[oEI[edgeIndex][0]-1][1]
eX2 = eC[oEI[edgeIndex][1]-1][0]
eY2 = eC[oEI[edgeIndex][1]-1][1]
origin = (eX1 * scale, eY1 * scale)
edgelen = sqrt((eX1 - eX2)**2 + (eY1 - eY2)**2)
edgesize = size * (edgelen / sidelen)
prevAngle = (oED[(edgeIndex - 1) % numOEI] + 180 - oED[edgeIndex]) % 360
nextAngle = (oED[edgeIndex] + 180 - oED[(edgeIndex + 1) % numOEI]) % 360
if str(angleOverride) in poly:
if angleOverride[poly].has_key('prev'):
if angleOverride[poly]['prev'].has_key(edgeIndex):
prevAngle = angleOverride[poly]['prev'][edgeIndex]
if angleOverride[poly].has_key('next'):
if angleOverride[poly]['next'].has_key(edgeIndex):
nextAngle = angleOverride[poly]['next'][edgeIndex]
trans = 'translate(' + str(origin[0]) + ',' + str(origin[1]) + ') rotate(' + str(oED[edgeIndex] ) + ') scale(' + str(edgesize/100.0) + ')'
prevAngle = (oED[(edgeIndex - 1) % numOEI] + 180 - oED[edgeIndex]) % 360
nextAngle = (oED[edgeIndex] + 180 - oED[(edgeIndex + 1) % numOEI]) % 360
if str(angleOverride) in poly:
if angleOverride[poly].has_key('prev'):
if angleOverride[poly]['prev'].has_key(edgeIndex):
prevAngle = angleOverride[poly]['prev'][edgeIndex]
if angleOverride[poly].has_key('next'):
if angleOverride[poly]['next'].has_key(edgeIndex):
nextAngle = angleOverride[poly]['next'][edgeIndex]
trans = 'translate(' + str(origin[0]) + ',' + str(origin[1]) + ') rotate(' + str(oED[edgeIndex] ) + ') scale(' + str(edgesize/100.0) + ')'
limitAngle = min(prevAngle, nextAngle)
tab = self.get_tab(limitAngle)
slot = self.get_slot(limitAngle)
limitAngle = min(prevAngle, nextAngle)
tab = self.get_tab(limitAngle)
slot = self.get_slot(limitAngle)
# the "special" tabs are all skewed one way or the other, to
# make room for tight turns. This determines if it is the previous
# or next angle that is the tight one, and flips the tab or slot if
# needed.
# the "special" tabs are all skewed one way or the other, to
# make room for tight turns. This determines if it is the previous
# or next angle that is the tight one, and flips the tab or slot if
# needed.
if(nextAngle == limitAngle):
trans += ' translate(100.0, 0) scale(-1,1)'
if(nextAngle == limitAngle):
trans += ' translate(100.0, 0) scale(-1,1)'
tab_group_attribs = {inkex.addNS('label','inkscape'):'tab', 'transform': trans }
tab_group = etree.SubElement(gsub, 'g', tab_group_attribs)
midX = (eX2 - eX1)/2 + eX1
midY = (eY2 - eY1)/2 + eY1
text_attrib = {'style': str(inkex.Style(textStyle)), 'x' : str(midX * scale), 'y' : str(midY * scale) }
# etree.SubElement(gsub, 'text', text_attrib).text = str(edgeIndex)
if ((edgeIndex % 2) == 0):
edgetype = tab
else:
edgetype = slot
tab_group_attribs = {inkex.addNS('label','inkscape'):'tab', 'transform': trans }
tab_group = etree.SubElement(gsub, 'g', tab_group_attribs)
midX = (eX2 - eX1)/2 + eX1
midY = (eY2 - eY1)/2 + eY1
text_attrib = {'style': str(inkex.Style(textStyle)), 'x' : str(midX * scale), 'y' : str(midY * scale) }
# etree.SubElement(gsub, 'text', text_attrib).text = str(edgeIndex)
if ((edgeIndex % 2) == 0):
edgetype = tab
else:
edgetype = slot
for path in edgetype['cut']:
gear_attribs = {'style':str(inkex.Style(cutStyle)), 'd':path}
gear = etree.SubElement(tab_group, inkex.addNS('path','svg'), gear_attribs )
for path in edgetype['cut']:
gear_attribs = {'style':str(inkex.Style(cutStyle)), 'd':path}
gear = etree.SubElement(tab_group, inkex.addNS('path','svg'), gear_attribs )
for path in edgetype['perf']:
gear_attribs = {'style':str(inkex.Style(perfStyle)), 'd':path}
gear = etree.SubElement(tab_group, inkex.addNS('path','svg'), gear_attribs )
for path in edgetype['perf']:
gear_attribs = {'style':str(inkex.Style(perfStyle)), 'd':path}
gear = etree.SubElement(tab_group, inkex.addNS('path','svg'), gear_attribs )
gsub_attribs = {inkex.addNS('label','inkscape'):'Polygon ' + str( poly ) + 'inside' }
gsub = etree.SubElement(g, 'g', gsub_attribs)
gsub_attribs = {inkex.addNS('label','inkscape'):'Polygon ' + str( poly ) + 'inside' }
gsub = etree.SubElement(g, 'g', gsub_attribs)
for edge in iEI:
points = [(eC[edge[0]-1][0] * scale, eC[edge[0]-1][1] * scale), (eC[edge[1]-1][0] * scale, eC[edge[1]-1][1] * scale)]
path = points_to_svgd( points )
perf_attribs = {'style':str(inkex.Style(perfStyle)), 'd':path}
gear = etree.SubElement(gsub, inkex.addNS('path','svg'), perf_attribs )
for edge in iEI:
points = [(eC[edge[0]-1][0] * scale, eC[edge[0]-1][1] * scale), (eC[edge[1]-1][0] * scale, eC[edge[1]-1][1] * scale)]
path = points_to_svgd( points )
perf_attribs = {'style':str(inkex.Style(perfStyle)), 'd':path}
gear = etree.SubElement(gsub, inkex.addNS('path','svg'), perf_attribs )
if __name__ == '__main__':
Polyhedra().run()
Polyhedra().run()

View File

@ -24,7 +24,7 @@ License: GNU GPL v3
Used version of Primitive: https://github.com/fogleman/primitive/commit/0373c216458be1c4b40655b796a3aefedf8b7d23
"""
class Primitive (inkex.Effect):
class Primitive (inkex.EffectExtension):
def rgbToHex(self, pickerColor):
longcolor = int(pickerColor)
@ -55,19 +55,18 @@ class Primitive (inkex.Effect):
if (os.path.isfile(path)):
return path
def __init__(self):
inkex.Effect.__init__(self)
self.arg_parser.add_argument("--keeporiginal", type=inkex.Boolean, default=False, help="Keep original image on canvas")
self.arg_parser.add_argument("--cliprect", type=inkex.Boolean, default=True, help="Draw clipping rectangle")
self.arg_parser.add_argument("--n", type=int, default=100, help="Number of shapes")
self.arg_parser.add_argument("--m", default=1, help="Mode")
self.arg_parser.add_argument("--rep", type=int, default=0,help="Extra shapes/iteration")
self.arg_parser.add_argument("--r", type=int, default=256, help="Resize to size before processing (px)")
self.arg_parser.add_argument("--s", type=int, default=1024, help="Output image size (px)")
self.arg_parser.add_argument("--a", type=int, default=128, help="Color alpha")
self.arg_parser.add_argument("--bg_enabled", type=inkex.Boolean, default=True, help="Use average starting background color")
self.arg_parser.add_argument("--bg", type=Color, default=255, help="Starting background color")
self.arg_parser.add_argument("--j", type=int, default=0, help="Number of parallel workers")
def add_arguments(self, pars):
pars.add_argument("--keeporiginal", type=inkex.Boolean, default=False, help="Keep original image on canvas")
pars.add_argument("--cliprect", type=inkex.Boolean, default=True, help="Draw clipping rectangle")
pars.add_argument("--n", type=int, default=100, help="Number of shapes")
pars.add_argument("--m", default=1, help="Mode")
pars.add_argument("--rep", type=int, default=0,help="Extra shapes/iteration")
pars.add_argument("--r", type=int, default=256, help="Resize to size before processing (px)")
pars.add_argument("--s", type=int, default=1024, help="Output image size (px)")
pars.add_argument("--a", type=int, default=128, help="Color alpha")
pars.add_argument("--bg_enabled", type=inkex.Boolean, default=True, help="Use average starting background color")
pars.add_argument("--bg", type=Color, default=255, help="Starting background color")
pars.add_argument("--j", type=int, default=0, help="Number of parallel workers")
def effect(self):

View File

@ -65,7 +65,7 @@ default=1,help="How compound paths are handled")
"""
class ReorderEffect(inkex.Effect):
class ReorderEffect(inkex.EffectExtension):
"""
Inkscape effect extension.
Re-order the objects in the SVG document for faster plotting.
@ -76,11 +76,9 @@ class ReorderEffect(inkex.Effect):
"""
def __init__( self ):
inkex.Effect.__init__( self )
self.arg_parser.add_argument( "--reordering",type=int, default=1, help="How groups are handled")
self.arg_parser.add_argument( "--preview_rendering",type=inkex.Boolean, default=False, help="Preview rendering") # Rendering is available for debug purposes. It only previews pen-up movements that are reordered and typically does not include all possible movement.
def add_arguments(self, pars):
pars.add_argument( "--reordering",type=int, default=1, help="How groups are handled")
pars.add_argument( "--preview_rendering",type=inkex.Boolean, default=False, help="Preview rendering") # Rendering is available for debug purposes. It only previews pen-up movements that are reordered and typically does not include all possible movement.
self.auto_rotate = True
def effect(self):

View File

@ -32,8 +32,10 @@ if debug:
else:
stderr = lambda msg: None
class RotateMinAll(inkex.Effect):
class RotateMinAll(inkex.EffectExtension):
def effect(self):
def duplicateNodes(aList):
clones={}
for id,node in aList.items():

View File

@ -31,7 +31,8 @@ if debug:
else:
stderr = lambda msg: None
class RotateMinBBox(inkex.Effect):
class RotateMinBBox(inkex.EffectExtension):
def effect(self):
for node in self.svg.selected.values():
min_bbox_angle = rotate_helper.optimal_rotations(node)[1]

View File

@ -31,7 +31,8 @@ if debug:
else:
stderr = lambda msg: None
class RotateMinWidth(inkex.Effect):
class RotateMinWidth(inkex.EffectExtension):
def effect(self):
for node in self.svg.selected.values():
min_width_angle = rotate_helper.optimal_rotations(node)[0]

View File

@ -36,25 +36,24 @@ End of Licensing paragraph.
import math, inkex
from sewing_patterns import *
class ShirtWaistAllington(inkex.Effect):
def __init__(self):
class ShirtWaistAllington(inkex.EffectExtension):
inkex.Effect.__init__(self)
self.arg_parser.add_argument('--m_unit', default = 'Inches', help = 'Centimeters or Inches?')
self.arg_parser.add_argument('--m_front_waist_length', type = float, default = '15.0', help = 'Front Waist Length')
self.arg_parser.add_argument('--m_back_waist_length', type = float, default = '15.5', help = 'Back Waist Length')
self.arg_parser.add_argument('--m_neck_circumference', type = float, default = '13.5', help = 'Neck Circumference')
self.arg_parser.add_argument('--m_bust_circumference', type = float, default = '39.0', help = 'Bust Circumference')
self.arg_parser.add_argument('--m_waist_circumference', type = float, default = '25.0', help = 'Waist Circumference')
self.arg_parser.add_argument('--m_armscye_circumference', type = float, default = '15.0', help = 'Armscye circumference')
self.arg_parser.add_argument('--m_across_back', type = float, default = '13.5', help = 'Across Back')
self.arg_parser.add_argument('--m_shoulder', type = float, default = '6.5', help = 'Shoulder')
self.arg_parser.add_argument('--m_side', type = float, default = '7.75', help = 'Side')
self.arg_parser.add_argument('--m_upper_front_height', type = float, default = '10.75', help = 'Upper Front Height')
self.arg_parser.add_argument('--m_overarm_length', type = float, default = '20.00', help = 'Overarm Length')
self.arg_parser.add_argument('--m_elbow_height', type = float, default = '9.50', help = 'Elbow Height - from wrist to elbow')
self.arg_parser.add_argument('--m_elbow_circumference', type = float, default = '12.50', help = 'Elbow Circumference - arm bent')
self.arg_parser.add_argument('--m_hand_circumference', type = float, default = '8.00', help = 'Hand Circumference')
def add_arguments(self, pars):
pars.add_argument('--m_unit', default = 'Inches', help = 'Centimeters or Inches?')
pars.add_argument('--m_front_waist_length', type = float, default = '15.0', help = 'Front Waist Length')
pars.add_argument('--m_back_waist_length', type = float, default = '15.5', help = 'Back Waist Length')
pars.add_argument('--m_neck_circumference', type = float, default = '13.5', help = 'Neck Circumference')
pars.add_argument('--m_bust_circumference', type = float, default = '39.0', help = 'Bust Circumference')
pars.add_argument('--m_waist_circumference', type = float, default = '25.0', help = 'Waist Circumference')
pars.add_argument('--m_armscye_circumference', type = float, default = '15.0', help = 'Armscye circumference')
pars.add_argument('--m_across_back', type = float, default = '13.5', help = 'Across Back')
pars.add_argument('--m_shoulder', type = float, default = '6.5', help = 'Shoulder')
pars.add_argument('--m_side', type = float, default = '7.75', help = 'Side')
pars.add_argument('--m_upper_front_height', type = float, default = '10.75', help = 'Upper Front Height')
pars.add_argument('--m_overarm_length', type = float, default = '20.00', help = 'Overarm Length')
pars.add_argument('--m_elbow_height', type = float, default = '9.50', help = 'Elbow Height - from wrist to elbow')
pars.add_argument('--m_elbow_circumference', type = float, default = '12.50', help = 'Elbow Circumference - arm bent')
pars.add_argument('--m_hand_circumference', type = float, default = '8.00', help = 'Hand Circumference')
def effect(self):

View File

@ -29,22 +29,21 @@ import subprocess
from lxml import etree
from inkex import Color
class SVGSudoku (inkex.Effect):
class SVGSudoku (inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self)
self.arg_parser.add_argument("--tab")
self.arg_parser.add_argument("--difficulty",default="mixed", help='How difficult to make puzzles.')
self.arg_parser.add_argument("--rows", type=int, default=1, help='Number of puzzle rows.')
self.arg_parser.add_argument("--cols", type=int, default=1, help='Number of puzzle columns.')
self.arg_parser.add_argument("--puzzle_size", type=int, default=6, help='The width & height of each puzzle.')
self.arg_parser.add_argument("--puzzle_gap", type=int, default=1, help='The space between puzzles.')
self.arg_parser.add_argument("--color_text", type=Color, default=255, help='Color for given numbers.')
self.arg_parser.add_argument("--color_bkgnd", type=Color, default=4243148799, help='Color for the puzzle background.')
self.arg_parser.add_argument("--color_puzzle",type=Color, default=2290779647, help='Border color for the puzzles.')
self.arg_parser.add_argument("--color_boxes", type=Color, default=3298820351, help='Border color for puzzle boxes.')
self.arg_parser.add_argument("--color_cells", type=Color, default=1923076095, help='Border color for the puzzle cells.')
self.arg_parser.add_argument("--units", help="The unit of the dimensions")
def add_arguments(self, pars):
pars.add_argument("--tab")
pars.add_argument("--difficulty",default="mixed", help='How difficult to make puzzles.')
pars.add_argument("--rows", type=int, default=1, help='Number of puzzle rows.')
pars.add_argument("--cols", type=int, default=1, help='Number of puzzle columns.')
pars.add_argument("--puzzle_size", type=int, default=6, help='The width & height of each puzzle.')
pars.add_argument("--puzzle_gap", type=int, default=1, help='The space between puzzles.')
pars.add_argument("--color_text", type=Color, default=255, help='Color for given numbers.')
pars.add_argument("--color_bkgnd", type=Color, default=4243148799, help='Color for the puzzle background.')
pars.add_argument("--color_puzzle",type=Color, default=2290779647, help='Border color for the puzzles.')
pars.add_argument("--color_boxes", type=Color, default=3298820351, help='Border color for puzzle boxes.')
pars.add_argument("--color_cells", type=Color, default=1923076095, help='Border color for the puzzle cells.')
pars.add_argument("--units", help="The unit of the dimensions")
def draw_grid(self, g_puz, x, y):
bkgnd_style = {'stroke':'none', 'stroke-width':'2', 'fill':self.options.color_bkgnd }

View File

@ -48,25 +48,25 @@ def colorString(pickerColor):
return '#' + format(longcolor >> 8, '06X')
class Grid_Triangular(inkex.Effect):
def __init__(self):
inkex.Effect.__init__(self)
self.arg_parser.add_argument("--tabs")
self.arg_parser.add_argument("--size_unit", default="mm", help="Unit for grid size")
self.arg_parser.add_argument("--y_divs", type=int, default=3, help="Major vertical divisions")
self.arg_parser.add_argument("--x_divs", type=int, default=3, help="Major horizontal divisions")
self.arg_parser.add_argument("--grid_angle", type=float, default=30.0, help="Angle between X axis and triangular grid lines")
self.arg_parser.add_argument("--dm", type=float, default=100.0, help="Major grid division spacing")
self.arg_parser.add_argument("--subdivs", type=int, default=5, help="Subdivisions per major grid division")
self.arg_parser.add_argument("--subsubdivs", type=int, default=2, help="Subsubdivisions per minor grid subdivision")
self.arg_parser.add_argument("--border_th", type=float, default=3.0, help="Border Line thickness")
self.arg_parser.add_argument("--border_color", type=int, help="Border line color")
self.arg_parser.add_argument("--major_th", type=float, default=2.0, help="Major grid division line thickness")
self.arg_parser.add_argument("--major_color", type=int, help="Major grid division line color")
self.arg_parser.add_argument("--subdiv_th", type=float, default=1.0, help="Minor grid subdivision line thickness")
self.arg_parser.add_argument("--subdiv_color", type=int, help="Minor grid subdivision line color")
self.arg_parser.add_argument("--subsubdiv_th", type=float, default=1.0, help="Subminor grid division line thickness")
self.arg_parser.add_argument("--subsubdiv_color", type=int, help="Subminor grid division line color")
class Grid_Triangular(inkex.EffectExtension):
def add_arguments(self, pars):
pars.add_argument("--tabs")
pars.add_argument("--size_unit", default="mm", help="Unit for grid size")
pars.add_argument("--y_divs", type=int, default=3, help="Major vertical divisions")
pars.add_argument("--x_divs", type=int, default=3, help="Major horizontal divisions")
pars.add_argument("--grid_angle", type=float, default=30.0, help="Angle between X axis and triangular grid lines")
pars.add_argument("--dm", type=float, default=100.0, help="Major grid division spacing")
pars.add_argument("--subdivs", type=int, default=5, help="Subdivisions per major grid division")
pars.add_argument("--subsubdivs", type=int, default=2, help="Subsubdivisions per minor grid subdivision")
pars.add_argument("--border_th", type=float, default=3.0, help="Border Line thickness")
pars.add_argument("--border_color", type=int, help="Border line color")
pars.add_argument("--major_th", type=float, default=2.0, help="Major grid division line thickness")
pars.add_argument("--major_color", type=int, help="Major grid division line color")
pars.add_argument("--subdiv_th", type=float, default=1.0, help="Minor grid subdivision line thickness")
pars.add_argument("--subdiv_color", type=int, help="Minor grid subdivision line color")
pars.add_argument("--subsubdiv_th", type=float, default=1.0, help="Subminor grid division line thickness")
pars.add_argument("--subsubdiv_color", type=int, help="Subminor grid division line color")
def EdgePoints(self,x0, y0, theta):
# find the intersection points of the line with the extended

View File

@ -34,15 +34,15 @@ from scipy.cluster.vq import kmeans2
import cv2
import urllib.request as urllib
class Triangulation(inkex.Effect):
def __init__(self):
inkex.Effect.__init__(self)
self.arg_parser.add_argument("-n", "--num_points", type=int, default=100, help="Number of points to be sampled")
self.arg_parser.add_argument("-m", "--edge_thresh_min", type=int, default=200, help="Minimum threshold for edge detection")
self.arg_parser.add_argument("-M", "--edge_thresh_max", type=int, default=255, help="Maximum threshold for edge detection")
self.arg_parser.add_argument("-c", "--add_corners", type=inkex.Boolean, default=0, help="Use corners for triangulation?")
self.arg_parser.add_argument("-g", "--gradient_fill", type=inkex.Boolean, default=0, help="Fill triangles with gradient?")
self.arg_parser.add_argument("-b", "--tab", default='', help="The tab of the interface")
class Triangulation(inkex.EffectExtension):
def add_arguments(self, pars):
pars.add_argument("-n", "--num_points", type=int, default=100, help="Number of points to be sampled")
pars.add_argument("-m", "--edge_thresh_min", type=int, default=200, help="Minimum threshold for edge detection")
pars.add_argument("-M", "--edge_thresh_max", type=int, default=255, help="Maximum threshold for edge detection")
pars.add_argument("-c", "--add_corners", type=inkex.Boolean, default=0, help="Use corners for triangulation?")
pars.add_argument("-g", "--gradient_fill", type=inkex.Boolean, default=0, help="Fill triangles with gradient?")
pars.add_argument("-b", "--tab", default='', help="The tab of the interface")
def draw_SVG_path(self, points, closed, style, parent):
pathdesc = "M "

View File

@ -23,9 +23,7 @@ from math import *
import inkex
from inkex.paths import Path, CubicSuperPath
class VHToLine(inkex.Effect):
def __init__(self):
inkex.Effect.__init__(self)
class VHToLine(inkex.EffectExtension):
def effect(self):
if len(self.svg.selected) == 0: exit("Please select at least one path.")

View File

@ -27,9 +27,7 @@ import sys
import inkex
from inkex import Transform
class SetViewBoxEffect(inkex.Effect):
def __init__(self):
inkex.Effect.__init__(self)
class SetViewBoxEffect(inkex.EffectExtension):
def effect(self):
if len(self.svg.selected) != 1:

View File

@ -54,81 +54,80 @@ Todo's
class vpypetools (inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self)
def add_arguments(self, pars):
# Line Sorting
self.arg_parser.add_argument("--linesort", type=inkex.Boolean, default=False)
self.arg_parser.add_argument("--linesort_no_flip", type=inkex.Boolean, default=False, help="Disable reversing stroke direction for optimization")
pars.add_argument("--linesort", type=inkex.Boolean, default=False)
pars.add_argument("--linesort_no_flip", type=inkex.Boolean, default=False, help="Disable reversing stroke direction for optimization")
# Line Merging
self.arg_parser.add_argument("--linemerge", type=inkex.Boolean, default=False)
self.arg_parser.add_argument("--linemerge_tolerance", type=float, default=0.500, help="Maximum distance between two line endings that should be merged (default 0.500 mm)")
self.arg_parser.add_argument("--linemerge_no_flip", type=inkex.Boolean, default=False, help="Disable reversing stroke direction for merging")
pars.add_argument("--linemerge", type=inkex.Boolean, default=False)
pars.add_argument("--linemerge_tolerance", type=float, default=0.500, help="Maximum distance between two line endings that should be merged (default 0.500 mm)")
pars.add_argument("--linemerge_no_flip", type=inkex.Boolean, default=False, help="Disable reversing stroke direction for merging")
# Trimming
self.arg_parser.add_argument("--trim", type=inkex.Boolean, default=False)
self.arg_parser.add_argument("--trim_x_margin", type=float, default=0.000, help="trim margin - x direction (mm)") # keep default at 0.000 to keep clean bbox
self.arg_parser.add_argument("--trim_y_margin", type=float, default=0.000, help="trim margin - y direction (mm)") # keep default at 0.000 to keep clean bbox
pars.add_argument("--trim", type=inkex.Boolean, default=False)
pars.add_argument("--trim_x_margin", type=float, default=0.000, help="trim margin - x direction (mm)") # keep default at 0.000 to keep clean bbox
pars.add_argument("--trim_y_margin", type=float, default=0.000, help="trim margin - y direction (mm)") # keep default at 0.000 to keep clean bbox
# Relooping
self.arg_parser.add_argument("--reloop", type=inkex.Boolean, default=False)
self.arg_parser.add_argument("--reloop_tolerance", type=float, default=0.500, help="Controls how close the path beginning and end must be to consider it closed (default 0.500 mm)")
pars.add_argument("--reloop", type=inkex.Boolean, default=False)
pars.add_argument("--reloop_tolerance", type=float, default=0.500, help="Controls how close the path beginning and end must be to consider it closed (default 0.500 mm)")
# Multipass
self.arg_parser.add_argument("--multipass", type=inkex.Boolean, default=False)
self.arg_parser.add_argument("--multipass_count", type=int, default=2, help="How many passes for each line (default 2)")
pars.add_argument("--multipass", type=inkex.Boolean, default=False)
pars.add_argument("--multipass_count", type=int, default=2, help="How many passes for each line (default 2)")
# Filter
self.arg_parser.add_argument("--filter", type=inkex.Boolean, default=False)
self.arg_parser.add_argument("--filter_tolerance", type=float, default=0.050, help="Tolerance used to determined if a line is closed or not (default 0.050 mm)")
self.arg_parser.add_argument("--filter_closed", type=inkex.Boolean, default=False, help="Keep closed lines")
self.arg_parser.add_argument("--filter_not_closed", type=inkex.Boolean, default=False, help="Keep open lines")
self.arg_parser.add_argument("--filter_min_length_enabled", type=inkex.Boolean, default=False, help="filter by min length")
self.arg_parser.add_argument("--filter_min_length", type=float, default=0.000, help="Keep lines whose length isn't shorter than value")
self.arg_parser.add_argument("--filter_max_length_enabled", type=inkex.Boolean, default=False, help="filter by max length")
self.arg_parser.add_argument("--filter_max_length", type=float, default=0.000, help="Keep lines whose length isn't greater than value")
pars.add_argument("--filter", type=inkex.Boolean, default=False)
pars.add_argument("--filter_tolerance", type=float, default=0.050, help="Tolerance used to determined if a line is closed or not (default 0.050 mm)")
pars.add_argument("--filter_closed", type=inkex.Boolean, default=False, help="Keep closed lines")
pars.add_argument("--filter_not_closed", type=inkex.Boolean, default=False, help="Keep open lines")
pars.add_argument("--filter_min_length_enabled", type=inkex.Boolean, default=False, help="filter by min length")
pars.add_argument("--filter_min_length", type=float, default=0.000, help="Keep lines whose length isn't shorter than value")
pars.add_argument("--filter_max_length_enabled", type=inkex.Boolean, default=False, help="filter by max length")
pars.add_argument("--filter_max_length", type=float, default=0.000, help="Keep lines whose length isn't greater than value")
# Split All
self.arg_parser.add_argument("--splitall", type=inkex.Boolean, default=False)
pars.add_argument("--splitall", type=inkex.Boolean, default=False)
# Plugin Occult
self.arg_parser.add_argument("--plugin_occult", type=inkex.Boolean, default=False)
self.arg_parser.add_argument("--plugin_occult_tolerance", type=float, default=0.01, help="Max distance between start and end point to consider a path closed (default 0.01 mm)")
self.arg_parser.add_argument("--plugin_occult_keepseparatelayer", type=inkex.Boolean, default=False, help="Put occulted lines to separate layer")
pars.add_argument("--plugin_occult", type=inkex.Boolean, default=False)
pars.add_argument("--plugin_occult_tolerance", type=float, default=0.01, help="Max distance between start and end point to consider a path closed (default 0.01 mm)")
pars.add_argument("--plugin_occult_keepseparatelayer", type=inkex.Boolean, default=False, help="Put occulted lines to separate layer")
# Free Mode
self.arg_parser.add_argument("--tab")
self.arg_parser.add_argument("--freemode", type=inkex.Boolean, default=False)
self.arg_parser.add_argument("--freemode_cmd1", default="")
self.arg_parser.add_argument("--freemode_cmd1_enabled", type=inkex.Boolean, default=True)
self.arg_parser.add_argument("--freemode_cmd2", default="")
self.arg_parser.add_argument("--freemode_cmd2_enabled", type=inkex.Boolean, default=False)
self.arg_parser.add_argument("--freemode_cmd3", default="")
self.arg_parser.add_argument("--freemode_cmd3_enabled", type=inkex.Boolean, default=False)
self.arg_parser.add_argument("--freemode_cmd4", default="")
self.arg_parser.add_argument("--freemode_cmd4_enabled", type=inkex.Boolean, default=False)
self.arg_parser.add_argument("--freemode_cmd5", default="")
self.arg_parser.add_argument("--freemode_cmd5_enabled", type=inkex.Boolean, default=False)
self.arg_parser.add_argument("--freemode_show_cmd", type=inkex.Boolean, default=False)
pars.add_argument("--tab")
pars.add_argument("--freemode", type=inkex.Boolean, default=False)
pars.add_argument("--freemode_cmd1", default="")
pars.add_argument("--freemode_cmd1_enabled", type=inkex.Boolean, default=True)
pars.add_argument("--freemode_cmd2", default="")
pars.add_argument("--freemode_cmd2_enabled", type=inkex.Boolean, default=False)
pars.add_argument("--freemode_cmd3", default="")
pars.add_argument("--freemode_cmd3_enabled", type=inkex.Boolean, default=False)
pars.add_argument("--freemode_cmd4", default="")
pars.add_argument("--freemode_cmd4_enabled", type=inkex.Boolean, default=False)
pars.add_argument("--freemode_cmd5", default="")
pars.add_argument("--freemode_cmd5_enabled", type=inkex.Boolean, default=False)
pars.add_argument("--freemode_show_cmd", type=inkex.Boolean, default=False)
# General Settings
self.arg_parser.add_argument("--input_handling", default="paths", help="Input handling")
self.arg_parser.add_argument("--flattenbezier", type=inkex.Boolean, default=False, help="Flatten bezier curves to polylines")
self.arg_parser.add_argument("--flatness", type=float, default=0.1, help="Minimum flatness = 0.1. The smaller the value the more fine segments you will get (quantization).")
self.arg_parser.add_argument("--decimals", type=int, default=3, help="Accuracy for imported lines' coordinates into vpype. Does not work for 'Multilayer/document'")
self.arg_parser.add_argument("--simplify", type=inkex.Boolean, default=False, help="Reduces significantly the number of segments used to approximate the curve while still guaranteeing an accurate conversion, but may increase the execution time. Does not work for 'Singlelayer/paths'")
self.arg_parser.add_argument("--parallel", type=inkex.Boolean, default=False, help="Enables multiprocessing for the SVG conversion. This is recommended ONLY when using 'Simplify geometry' on large SVG files with many curved elements. Does not work for 'Singlelayer/paths'")
self.arg_parser.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("--output_show", type=inkex.Boolean, default=False, help="This will open a separate window showing the finished SVG data. If enabled, output is not applied to InkScape canvas (only for preview)!")
self.arg_parser.add_argument("--output_show_points", type=inkex.Boolean, default=False, help="Enable point display in viewer")
self.arg_parser.add_argument("--output_stats", type=inkex.Boolean, default=False, help="Show output statistics before/after conversion")
self.arg_parser.add_argument("--output_trajectories", type=inkex.Boolean, default=False, help="Add paths for the travel trajectories")
self.arg_parser.add_argument("--keep_objects", type=inkex.Boolean, default=False, help="If false, selected paths will be removed")
self.arg_parser.add_argument("--strokes_to_paths", type=inkex.Boolean, default=True, help="Recommended option. Performs 'Path' > 'Stroke to Path' (CTRL + ALT + C) to convert vpype converted lines back to regular path objects")
self.arg_parser.add_argument("--use_style_of_first_element", type=inkex.Boolean, default=True, help="If enabled the first element in selection is scanned and we apply it's style to all imported vpype lines (but not for trajectories). Does not work for 'Multilayer/document'")
self.arg_parser.add_argument("--lines_stroke_width", type=float, default=1.0, help="Stroke width of tooling lines (px). Gets overwritten if 'Use style of first selected element' is enabled")
self.arg_parser.add_argument("--trajectories_stroke_width", type=float, default=1.0, help="Stroke width of trajectory lines (px). Gets overwritten if 'Use style of first selected element' is enabled")
pars.add_argument("--input_handling", default="paths", help="Input handling")
pars.add_argument("--flattenbezier", type=inkex.Boolean, default=False, help="Flatten bezier curves to polylines")
pars.add_argument("--flatness", type=float, default=0.1, help="Minimum flatness = 0.1. The smaller the value the more fine segments you will get (quantization).")
pars.add_argument("--decimals", type=int, default=3, help="Accuracy for imported lines' coordinates into vpype. Does not work for 'Multilayer/document'")
pars.add_argument("--simplify", type=inkex.Boolean, default=False, help="Reduces significantly the number of segments used to approximate the curve while still guaranteeing an accurate conversion, but may increase the execution time. Does not work for 'Singlelayer/paths'")
pars.add_argument("--parallel", type=inkex.Boolean, default=False, help="Enables multiprocessing for the SVG conversion. This is recommended ONLY when using 'Simplify geometry' on large SVG files with many curved elements. Does not work for 'Singlelayer/paths'")
pars.add_argument("--apply_transformations", type=inkex.Boolean, default=False, help="Run 'Apply Transformations' extension before running vpype. Helps avoiding geometry shifting")
pars.add_argument("--output_show", type=inkex.Boolean, default=False, help="This will open a separate window showing the finished SVG data. If enabled, output is not applied to InkScape canvas (only for preview)!")
pars.add_argument("--output_show_points", type=inkex.Boolean, default=False, help="Enable point display in viewer")
pars.add_argument("--output_stats", type=inkex.Boolean, default=False, help="Show output statistics before/after conversion")
pars.add_argument("--output_trajectories", type=inkex.Boolean, default=False, help="Add paths for the travel trajectories")
pars.add_argument("--keep_objects", type=inkex.Boolean, default=False, help="If false, selected paths will be removed")
pars.add_argument("--strokes_to_paths", type=inkex.Boolean, default=True, help="Recommended option. Performs 'Path' > 'Stroke to Path' (CTRL + ALT + C) to convert vpype converted lines back to regular path objects")
pars.add_argument("--use_style_of_first_element", type=inkex.Boolean, default=True, help="If enabled the first element in selection is scanned and we apply it's style to all imported vpype lines (but not for trajectories). Does not work for 'Multilayer/document'")
pars.add_argument("--lines_stroke_width", type=float, default=1.0, help="Stroke width of tooling lines (px). Gets overwritten if 'Use style of first selected element' is enabled")
pars.add_argument("--trajectories_stroke_width", type=float, default=1.0, help="Stroke width of trajectory lines (px). Gets overwritten if 'Use style of first selected element' is enabled")
def effect(self):
lc = vpype.LineCollection() # create a new array of LineStrings consisting of Points. We convert selected paths to polylines and grab their points

View File

@ -11,17 +11,16 @@ def addPathCommand(a, cmd):
for x in cmd:
a.append(str(x))
class XGramEffect(inkex.Effect):
class XGramEffect(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self)
self.arg_parser.add_argument('--tab')
self.arg_parser.add_argument('--points', type=int, default=5, help='Number of points (or sides)')
self.arg_parser.add_argument('--skip', type=int, default=2, help='Vertex increment when connecting points')
self.arg_parser.add_argument('--rotate', type=float, default=0, help='Rotation angle (clockwise, in degrees)')
self.arg_parser.add_argument('--inner_circle', type=inkex.Boolean, default=False, help='Connect points via inner circle')
self.arg_parser.add_argument('--show_inner_circle', type=inkex.Boolean, default=True, help='Show inner circle')
self.arg_parser.add_argument('--inner_ratio', type=int, default=50, help='Inner radius percentage (inner radius as a percentage of the outer radius)')
def add_arguments(self, pars):
pars.add_argument('--tab')
pars.add_argument('--points', type=int, default=5, help='Number of points (or sides)')
pars.add_argument('--skip', type=int, default=2, help='Vertex increment when connecting points')
pars.add_argument('--rotate', type=float, default=0, help='Rotation angle (clockwise, in degrees)')
pars.add_argument('--inner_circle', type=inkex.Boolean, default=False, help='Connect points via inner circle')
pars.add_argument('--show_inner_circle', type=inkex.Boolean, default=True, help='Show inner circle')
pars.add_argument('--inner_ratio', type=int, default=50, help='Inner radius percentage (inner radius as a percentage of the outer radius)')
def effect(self):
layer = self.svg.get_current_layer();

View File

@ -47,11 +47,12 @@ def randomize(x,y, r):
y = math.sin(a-math.pi/2)*r
return [x, y]
class RadiusRandomize(inkex.Effect):
def __init__(self):
inkex.Effect.__init__(self)
self.arg_parser.add_argument("--title")
self.arg_parser.add_argument("--radius", type=float, default=10.0, help="Randomly move control and end points in this radius")
class RadiusRandomize(inkex.EffectExtension):
def add_arguments(self, pars):
pars.add_argument("--title")
pars.add_argument("--radius", type=float, default=10.0, help="Randomly move control and end points in this radius")
def effect(self):
for id, node in self.svg.selected.items():
if node.tag == inkex.addNS('path','svg'):

View File

@ -33,23 +33,22 @@ def draw_SVG_circle(parent, r, cx, cy, name, style):
Black = '#000000'
class Zoetrope(inkex.Effect):
class Zoetrope(inkex.EffectExtension):
def __init__(self):
inkex.Effect.__init__(self) # initialize the super class
self.arg_parser.add_argument("-u", "--units", default='mm', help="Units this dialog is using")
self.arg_parser.add_argument("-d", "--diameter", type=float, default=1.0, help="Diameter of disk")
self.arg_parser.add_argument("-n", "--divisions", type=int, default=24, help="Number of divisions")
self.arg_parser.add_argument("-i", "--height", type=float, default=1.0, help="Image height")
self.arg_parser.add_argument("-t", "--trigger", type=inkex.Boolean, default=False, help="Trigger")
self.arg_parser.add_argument("-q", "--triggerradius", type=float, default=1.0, help="Height of trigger line")
self.arg_parser.add_argument("-e", "--thick", type=float, default=1.0, help="Thickness of trigger line")
self.arg_parser.add_argument("-r", "--ratio", type=float, default=0.5, help="Ratio of trigger pulse")
self.arg_parser.add_argument("-p", "--phase", type=float, default=0, help="Delay of trigger pulse")
self.arg_parser.add_argument("-w", "--stroke_width", type=float, default=0.1, help="Line thickness")
self.arg_parser.add_argument("-m", "--template", type=inkex.Boolean, default=False, help="Show Image Distortion template")
self.arg_parser.add_argument("-k", "--dpi", type=int, default=300, help="To calculate useful image size")
self.arg_parser.add_argument("--active-tab", default='', help="Active tab. Not used now.")
def add_arguments(self, pars):
pars.add_argument("-u", "--units", default='mm', help="Units this dialog is using")
pars.add_argument("-d", "--diameter", type=float, default=1.0, help="Diameter of disk")
pars.add_argument("-n", "--divisions", type=int, default=24, help="Number of divisions")
pars.add_argument("-i", "--height", type=float, default=1.0, help="Image height")
pars.add_argument("-t", "--trigger", type=inkex.Boolean, default=False, help="Trigger")
pars.add_argument("-q", "--triggerradius", type=float, default=1.0, help="Height of trigger line")
pars.add_argument("-e", "--thick", type=float, default=1.0, help="Thickness of trigger line")
pars.add_argument("-r", "--ratio", type=float, default=0.5, help="Ratio of trigger pulse")
pars.add_argument("-p", "--phase", type=float, default=0, help="Delay of trigger pulse")
pars.add_argument("-w", "--stroke_width", type=float, default=0.1, help="Line thickness")
pars.add_argument("-m", "--template", type=inkex.Boolean, default=False, help="Show Image Distortion template")
pars.add_argument("-k", "--dpi", type=int, default=300, help="To calculate useful image size")
pars.add_argument("--active-tab", default='', help="Active tab. Not used now.")
def calc_unit_factor(self):
""" return the scale factor for all dimension conversions.