This commit is contained in:
Mario Voigt 2022-12-06 22:37:33 +01:00
parent 397cb23d52
commit 86e5713af6
32 changed files with 167 additions and 403 deletions

View File

@ -4,10 +4,8 @@ from inkscape_helper.Coordinate import Coordinate
import inkscape_helper.Effect as eff
import inkscape_helper.SVG as svg
from inkscape_helper.Ellipse import Ellipse
from inkscape_helper.Line import Line
from inkscape_helper.EllipticArc import EllipticArc
from math import *
import inkex

View File

@ -1,5 +1,4 @@
import inkex
import simplestyle
from lxml import etree
def _format_1st(command, is_absolute):

View File

@ -2,9 +2,6 @@
# We will use the inkex module with the predefined Effect base class.
import inkex
# The simplestyle module provides functions for style parsing.
import simplestyle
import math
from lxml import etree

View File

@ -60,7 +60,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
'''
__version__ = "1.0" ### please report bugs, suggestions etc at https://github.com/paulh-rnd/TabbedBoxMaker ###
import os,sys,inkex,simplestyle,gettext,math
import os
import sys
import inkex
import gettext
import math
from copy import deepcopy
_ = gettext.gettext
@ -91,18 +95,6 @@ def getCircle(r, c):
log("putting circle at (%d,%d)" % (cx,cy))
circle = inkex.PathElement.arc((cx, cy), r)
circle.style = { 'stroke': '#000000', 'stroke-width': str(linethickness), 'fill': 'none' }
# ell_attribs = {'style':simplestyle.formatStyle(style),
# inkex.addNS('cx','sodipodi') :str(cx),
# inkex.addNS('cy','sodipodi') :str(cy),
# inkex.addNS('rx','sodipodi') :str(r),
# inkex.addNS('ry','sodipodi') :str(r),
# inkex.addNS('start','sodipodi') :str(0),
# inkex.addNS('end','sodipodi') :str(2*math.pi),
# inkex.addNS('open','sodipodi') :'true', #all ellipse sectors we will draw are open
# inkex.addNS('type','sodipodi') :'arc',
# 'transform' :'' }
#inkex.etree.SubElement(parent, inkex.addNS('path','svg'), ell_attribs )
return circle
def dimpleStr(tabVector,vectorX,vectorY,dirX,dirY,dirxN,diryN,ddir,isTab):

View File

@ -0,0 +1,20 @@
[
{
"name": "<various>",
"id": "info.festi.boxes.py.<various>",
"path": "boxes.py",
"dependent_extensions": null,
"original_name": "<various>",
"original_id": "info.festi.boxes.py.<various>",
"license": "GNU GPL v3",
"license_url": "https://github.com/florianfesti/boxes/blob/master/LICENSE.txt",
"comment": "",
"source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.2/src/branch/master/extensions/fablabchemnitz/boxes.py",
"fork_url": "https://github.com/florianfesti/boxes",
"documentation_url": "https://stadtfabrikanten.org/display/IFM/Boxes.py",
"inkscape_gallery_url": null,
"main_authors": [
"github.com/eridur-de"
]
}
]

View File

@ -27,7 +27,6 @@ import inkex
import sys
from inkex.paths import Path
class DestructiveClip(inkex.EffectExtension):
def __init__(self):

View File

@ -62,7 +62,6 @@ class ExponentialDistort(inkex.EffectExtension):
return x
def computeBBox(self, pts):
""" 'improved' version of simplepath.computeBBox, this one includes b-spline handles."""
xmin = None
xmax = None
ymin = None

View File

@ -7,7 +7,6 @@ Only the first segment of a multi-segment line will be used.
'''
import inkex
from inkex.paths import Path
import simplepath
from math import *
from lxml import etree

View File

@ -36,7 +36,6 @@ import sys
from lxml import etree
import inkex
import simpletransform
import simplestyle
import plot_utils
"""

View File

@ -20,8 +20,12 @@ barraud@math.univ-lille1.fr
This code defines several functions to make handling of transform
attribute easier.
'''
import inkex, cubicsuperpath, bezmisc, simplestyle
import copy, math, re
import inkex
import cubicsuperpath
import bezmisc
import copy
import math
import re
def parseTransform(transf,mat=[[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]):
if transf=="" or transf==None:

View File

@ -5,28 +5,9 @@ Defines a path and what it is supposed to be (mountain, valley, edge)
"""
import inkex # Required
import simplestyle # will be needed here for styles support
# compatibility hack
try:
from lxml import etree
inkex.etree = etree
except:
pass
import inkex
from math import sin, cos, pi, sqrt
# compatibility hack for formatStyle
def format_style(style):
try:
return str(inkex.Style(style)) # new
except:
return simplestyle.formatStyle(style) # old
# def format_style(style):
# return simplestyle.formatStyle(style)
from lxml import etree
class Path:
""" Class that defines an svg stroke to be drawn in Inkscape
@ -166,7 +147,7 @@ class Path:
- Draws strokes defined on "path_tree" to "group"
- Inputs:
-- path_tree [nested list] of Path instances
-- group [inkex.etree.SubElement]
-- group [etree.SubElement]
-- styles_dict [dict] containing all styles for path_tree
"""
@staticmethod
@ -178,7 +159,7 @@ class Path:
if len(subpath) == 1:
subgroup = group
else:
subgroup = inkex.etree.SubElement(group, 'g')
subgroup = etree.SubElement(group, 'g')
Path.draw_paths_recursively(subpath, subgroup, styles_dict)
else:
# ~ if subpath.style != 'n':
@ -192,16 +173,16 @@ class Path:
if subpath.closed:
path = path + 'L{},{} Z'.format(*points[0])
attribs = {'style': format_style(styles_dict[subpath.style]),
attribs = {'style': str(inkex.Style(styles_dict[subpath.style])),
'd': path,
'opacity': str(subpath.fold_angle/180)}
inkex.etree.SubElement(group, inkex.addNS('path', 'svg'), attribs)
etree.SubElement(group, inkex.addNS('path', 'svg'), attribs)
else:
attribs = {'style': format_style(styles_dict[subpath.style]),
attribs = {'style': str(inkex.Style(styles_dict[subpath.style])),
'cx': str(subpath.points[0][0]), 'cy': str(subpath.points[0][1]),
'r': str(subpath.radius),
'opacity': str(subpath.fold_angle/180)}
inkex.etree.SubElement(group, inkex.addNS('circle', 'svg'), attribs)
etree.SubElement(group, inkex.addNS('circle', 'svg'), attribs)
@classmethod
def get_average_point(cls, paths):

View File

@ -1,4 +1,4 @@
#! /usr/bin/env python
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Helper functions
@ -6,10 +6,11 @@ Helper functions
"""
import os
from abc import abstractmethod
from Path import Path
import inkex
from lxml import etree
from Path import Path, inkex, simplestyle
class Pattern(inkex.Effect):
class Pattern(inkex.EffectExtension):
""" Class that inherits inkex.Effect and further specializes it for different
Patterns generation
@ -21,7 +22,7 @@ class Pattern(inkex.Effect):
'v' : valley_style,
'e' : edge_style}
topgroup: inkex.etree.SubElement
topgroup: etree.SubElement
Top Inkscape group element
path_tree: nested list
@ -89,13 +90,6 @@ class Pattern(inkex.Effect):
self.float = "float"
self.bool = "inkbool"
# Two ways to get debug info:
# OR just use inkex.debug(string) instead...
try:
self.tty = open("/dev/tty", 'w')
except:
self.tty = open(os.devnull, 'w') # '/dev/null' for POSIX, 'nul' for Windows.
self.add_argument('-u', '--units', type=self.str, default='mm')
# bypass most style options for OrigamiSimulator
@ -225,7 +219,7 @@ class Pattern(inkex.Effect):
# add the group to the document's current layer
if type(self.path_tree) == list and len(self.path_tree) != 1:
self.topgroup = inkex.etree.SubElement(self.get_layer(), 'g', g_attribs)
self.topgroup = etree.SubElement(self.get_layer(), 'g', g_attribs)
else:
self.topgroup = self.get_layer()
@ -242,12 +236,7 @@ class Pattern(inkex.Effect):
# compatibility hack, "affect()" is replaced by "run()"
def draw(self):
try:
self.run() # new
except:
self.affect() # old
# close(self.tty)
self.tty.close()
self.run() # new
# compatibility hack
def get_layer(self):
@ -346,11 +335,11 @@ class Pattern(inkex.Effect):
'fill': '#F6921E', 'font-family': 'Bitstream Vera Sans,sans-serif',
'text-anchor': 'middle', 'text-align': 'center'}
line_attribs = {inkex.addNS('label','inkscape'): 'Annotation',
'style': simplestyle.formatStyle(line_style),
'style': inkex.Style(line_style),
'x': str(position[0]),
'y': str((position[1] + text_height) * 1.2)
}
line = inkex.etree.SubElement(node, inkex.addNS('text','svg'), line_attribs)
line = etree.SubElement(node, inkex.addNS('text','svg'), line_attribs)
line.text = text
@ -370,9 +359,3 @@ class Pattern(inkex.Effect):
return inkex.unittouu(str(1.0) + self.options.units)
except AttributeError:
return self.unittouu(str(1.0) + self.options.units)

View File

@ -58,8 +58,8 @@
<effect>
<object-type>all</object-type>
<effects-menu>
<submenu name="Origami Patterns">
<submenu name="Boxes" />
<submenu name="FabLab Chemnitz Boxes/Papercraft">
<submenu name="Paper/Cardboard Boxes" />
</submenu>
</effects-menu>
</effect>

View File

@ -54,8 +54,10 @@
<effect>
<object-type>all</object-type>
<effects-menu>
<submenu name="Origami Patterns">
<submenu name="Boxes" />
<submenu name="FabLab Chemnitz Boxes/Papercraft">
<submenu name="Origami Patterns">
<submenu name="Boxes" />
</submenu>
</submenu>
</effects-menu>
</effect>

View File

@ -10,13 +10,13 @@
<option value="kirigami1">Kirigami mode 1</option>
<option value="kirigami2">Kirigami mode 2</option>
</param>
<label>------------------------------------------------------------</label>
<separator/>
<param name="n" type="int" min="3" max="25" gui-text="Number of sides of polygon">6</param>
<param name="lines" type="int" min="1" max="100" gui-text="Number of cells">3</param>
<label>------------------------------------------------------------</label>
<separator/>
<param name="radius" type="float" max="10000" precision="3" gui-text="Radius of bigger polygon">25.0</param>
<param name="radial_ratio" type="float" max="1.0" min="0.0001" precision="3" gui-text="Ratio small radius/big radius">0.75</param>
<label>------------------------------------------------------------</label>
<separator/>
<param name="parameter_type" type="optiongroup" appearance="combo" gui-text="Parameter:">
<option value="angles">Angles (alpha1, alpha2)</option>
<option value="heights">Heights (h1, h2)</option>
@ -37,13 +37,13 @@
</page>
<page name="extra" gui-text="Extra">
<param name="add_attachment" type="bool" gui-text="Add attachments?">false</param>
<label>------------------------------------------------------------</label>
<separator/>
<param name="base_height" type="float" max="10000" precision="3" gui-text="Height of base">5.0</param>
<param name="add_base_slot" type="bool" gui-text="Add base slots?">false</param>
<param name="center_base_slot" type="bool" gui-text="Center base slots?">false</param>
<param name="base_slot_height" type="float" max="10000" precision="3" gui-text="Height of base slot">3.0</param>
<param name="base_slot_width" type="float" max="10000" precision="3" gui-text="Width of base slow">3.0</param>
<label>------------------------------------------------------------</label>
<separator/>
<param name="distance" type="float" max="10000" precision="3" gui-text="Distance between cells">3.0</param>
<param name="add_distance_slot" type="bool" gui-text="Add slots between cells?">false</param>
<param name="distance_slot_height" type="float" max="10000" precision="3" gui-text="Height of slots between cells">3.0</param>
@ -100,8 +100,8 @@
<effect>
<object-type>all</object-type>
<effects-menu>
<submenu name="Origami Patterns">
<submenu name="Cylindrical" />
<submenu name="FabLab Chemnitz Boxes/Papercraft">
<submenu name="Paper/Cardboard Boxes" />
</submenu>
</effects-menu>
</effect>

View File

@ -8,10 +8,10 @@
<option value="regular">Regular</option>
<option value="mirrowed">Mirror odd cells</option>
</param>
<label>------------------------------------------------------------</label>
<separator/>
<param name="rows" type="int" min="1" max="100" gui-text="Number of cells">3</param>
<param name="sides" type="int" min="3" max="100" gui-text="Number of polygon sides">6</param>
<label>------------------------------------------------------------</label>
<separator/>
<param name="measure_value" type="float" max="10000" precision="3" gui-text="Measure value:">10.0</param>
<param name="measure_type" type="optiongroup" appearance="combo" gui-text="Measure type:">
<option value="a">Polygon side (a)</option>
@ -30,7 +30,7 @@
<option value="px">px</option>
</param>
<param name="simulation_mode" type="bool" gui-text="Simulation mode">true</param>
<label>------------------------------------------------------------</label>
<separator/>
<param name="parameter_type" type="optiongroup" appearance="combo" gui-text="Parameter type:">
<option value="angle_ratio">Angle ratio (lambda)</option>
<option value="radial_ratio">Radial ratio</option>
@ -42,7 +42,7 @@
</page>
<page name="slots" gui-text="Slots">
<param name="extra_column" type="bool" gui-text="Extra column?">false</param>
<label>------------------------------------------------------------</label>
<separator/>
<param name="add_base_slot" type="bool" gui-text="Add base slots?">false</param>
<param name="base_slot_position" type="optiongroup" appearance="combo" gui-text="Base slot position:">
<option value="-1">Top</option>
@ -52,7 +52,7 @@
<param name="base_height" type="float" max="10000" precision="3" gui-text="Height of base">5.0</param>
<param name="base_slot_height" type="float" max="10000" precision="3" gui-text="Height of base slot">3.0</param>
<param name="base_slot_width" type="float" max="10000" precision="3" gui-text="Width of base slow">3.0</param>
<label>------------------------------------------------------------</label>
<separator/>
<param name="add_middle_slot" type="bool" gui-text="Add slots between cells?">false</param>
<param name="middle_slot_position" type="optiongroup" appearance="combo" gui-text="Middle slot position:">
<option value="-1">Top</option>
@ -111,8 +111,10 @@
<effect>
<object-type>all</object-type>
<effects-menu>
<submenu name="Origami Patterns">
<submenu name="Cylindrical" />
<submenu name="FabLab Chemnitz Boxes/Papercraft">
<submenu name="Origami Patterns">
<submenu name="Cylindrical" />
</submenu>
</submenu>
</effects-menu>
</effect>

View File

@ -1,15 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<name>* Cylindrical template effect</name>
<name>Cylindrical template effect</name>
<id>org.inkscape.Origami_patterns.cylindrical_template</id>
<param name="active-tab" type="notebook">
<page name="options" gui-text="Options">
<label>------------------------------------</label>
<separator/>
<label>Minimum necessary parameters for Cylindrical origami types :</label>
<param name="radius" type="float" max="10000" precision="3" gui-text="Radius of cylinder">10.0</param>
<param name="sides" type="int" min="3" max="25" gui-text="Number of sides of polygon">6</param>
<param name="rows" type="int" min="1" max="100" gui-text="Number of cells">3</param>
<label>-------------------------------------</label>
<separator/>
<param name="length" type="float" max="10000" precision="3" gui-text="Length">10.0</param>
<param name="angle" type="int" min="0" max="45" gui-text="Rotation angle (degree)">0</param>
<param name="units" type="optiongroup" appearance="combo" gui-text="Units">
@ -24,7 +24,7 @@
</page>
<page name="slots" gui-text="Slots">
<param name="extra_column" type="bool" gui-text="Extra column?">false</param>
<label>------------------------------------------------------------</label>
<separator/>
<param name="add_base_slot" type="bool" gui-text="Add base slots?">false</param>
<param name="base_slot_position" type="optiongroup" appearance="combo" gui-text="Base slot position:">
<option value="-1">Top</option>
@ -34,7 +34,7 @@
<param name="base_height" type="float" max="10000" precision="3" gui-text="Height of base">5.0</param>
<param name="base_slot_height" type="float" max="10000" precision="3" gui-text="Height of base slot">3.0</param>
<param name="base_slot_width" type="float" max="10000" precision="3" gui-text="Width of base slow">3.0</param>
<label>------------------------------------------------------------</label>
<separator/>
<param name="add_middle_slot" type="bool" gui-text="Add slots between cells?">false</param>
<param name="middle_slot_position" type="optiongroup" appearance="combo" gui-text="Middle slot position:">
<option value="-1">Top</option>
@ -84,8 +84,10 @@
<effect>
<object-type>all</object-type>
<effects-menu>
<submenu name="Origami Patterns">
<submenu name="Cylindrical" />
<submenu name="FabLab Chemnitz Boxes/Papercraft">
<submenu name="Origami Patterns">
<submenu name="Template submenu" />
</submenu>
</submenu>
</effects-menu>
</effect>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<name>* Support ring</name>
<name>Support ring</name>
<id>org.inkscape.Origami_patterns.support_ring</id>
<param name="active-tab" type="notebook">
<page name="options" gui-text="Options">
@ -8,19 +8,19 @@
<param name="radius_external" type="float" max="10000" precision="3" gui-text="Pattern radius:">10.0</param>
<param name="inverted" type="bool" gui-text="Invert hook direction?">false</param>
<param name="single_stroke" type="bool" gui-text="Single stroke?">true</param>
<label>------------------------------------------------------------</label>
<separator/>
<param name="connector_length" type="float" max="10000" precision="3" gui-text="Connector length:">3.0</param>
<param name="connector_thickness" type="float" max="10000" precision="3" gui-text="Connector thickness:">3.0</param>
<param name="head_length" type="float" max="10000" precision="3" gui-text="Head extra length:">1.0</param>
<param name="head_thickness" type="float" max="10000" precision="3" gui-text="Head extra thickness:">1.0</param>
<label>------------------------------------------------------------</label>
<separator/>
<param name="radius_draw" type="bool" gui-text="Draw internal radius? (or external, if inverted)">true</param>
<param name="radius_ratio" type="float" min="0" max="0.9" precision="3" gui-text="Radial ratio:">0.5</param>
<param name="radius_type" type="optiongroup" appearance="combo" gui-text="Internal radius type:">
<option value="polygonal">Polygonal</option>
<option value="circular">Circular</option>
</param>
<label>------------------------------------------------------------</label>
<separator/>
<label>Length must be at least the thickness of the origami material + the thickness of the belt.</label>
<label>For an OpenSCAD simple implementation of the belt, see Origami_Patterns/Support_Ring_Belt.</label>
<param name="units" type="optiongroup" appearance="combo" gui-text="Units">
@ -42,8 +42,10 @@
<effect>
<object-type>all</object-type>
<effects-menu>
<submenu name="Origami Patterns">
<submenu name="Cylindrical" />
<submenu name="FabLab Chemnitz Boxes/Papercraft">
<submenu name="Origami Patterns">
<submenu name="Cylindrical" />
</submenu>
</submenu>
</effects-menu>
</effect>

View File

@ -10,13 +10,13 @@
<option value="kirigami1">Kirigami mode 1</option>
<option value="kirigami2">Kirigami mode 2</option>
</param>
<label>------------------------------------------------------------</label>
<separator/>
<param name="n" type="int" min="3" max="25" gui-text="Number of sides of polygon">6</param>
<param name="lines" type="int" min="1" max="100" gui-text="Number of cells">3</param>
<label>------------------------------------------------------------</label>
<separator/>
<param name="radius" type="float" max="10000" precision="3" gui-text="Radius of bigger polygon">25.0</param>
<param name="radial_ratio" type="float" max="1.0" min="0.0001" precision="3" gui-text="Ratio small radius/big radius">0.75</param>
<label>------------------------------------------------------------</label>
<separator/>
<param name="parameter_type" type="optiongroup" appearance="combo" gui-text="Parameter:">
<option value="angles">Angles (alpha1, alpha2)</option>
<option value="heights">Heights (h1, h2)</option>
@ -37,13 +37,13 @@
</page>
<page name="extra" gui-text="Extra">
<param name="add_attachment" type="bool" gui-text="Add attachments?">false</param>
<label>------------------------------------------------------------</label>
<separator/>
<param name="base_height" type="float" max="10000" precision="3" gui-text="Height of base">5.0</param>
<param name="add_base_slot" type="bool" gui-text="Add base slots?">false</param>
<param name="center_base_slot" type="bool" gui-text="Center base slots?">false</param>
<param name="base_slot_height" type="float" max="10000" precision="3" gui-text="Height of base slot">3.0</param>
<param name="base_slot_width" type="float" max="10000" precision="3" gui-text="Width of base slow">3.0</param>
<label>------------------------------------------------------------</label>
<separator/>
<param name="distance" type="float" max="10000" precision="3" gui-text="Distance between cells">3.0</param>
<param name="add_distance_slot" type="bool" gui-text="Add slots between cells?">false</param>
<param name="distance_slot_height" type="float" max="10000" precision="3" gui-text="Height of slots between cells">3.0</param>
@ -96,8 +96,10 @@
<effect>
<object-type>all</object-type>
<effects-menu>
<submenu name="Origami Patterns">
<submenu name="Deprecated" />
<submenu name="FabLab Chemnitz Boxes/Papercraft">
<submenu name="Origami Patterns">
<submenu name="Deprecated" />
</submenu>
</submenu>
</effects-menu>
</effect>

View File

@ -8,10 +8,10 @@
<option value="regular">Regular</option>
<option value="mirrowed">Mirror odd cells</option>
</param>
<label>------------------------------------------------------------</label>
<separator/>
<param name="lines" type="int" min="1" max="100" gui-text="Number of cells">3</param>
<param name="sides" type="int" min="3" max="100" gui-text="Number of polygon sides">6</param>
<label>------------------------------------------------------------</label>
<separator/>
<param name="measure_value" type="float" max="10000" precision="3" gui-text="Measure value:">10.0</param>
<param name="measure_type" type="optiongroup" appearance="combo" gui-text="Measure type:">
<option value="a">Polygon side (a)</option>
@ -29,7 +29,7 @@
<option value="pt">pt</option>
<option value="px">px</option>
</param>
<label>------------------------------------------------------------</label>
<separator/>
<param name="parameter_type" type="optiongroup" appearance="combo" gui-text="Parameter type:">
<option value="angle_ratio">Angle ratio (lambda)</option>
<option value="radial_ratio">Radial ratio</option>
@ -43,7 +43,7 @@
<page name="extraoptions" gui-text="Extra Options">
<param name="add_attachment" type="bool" gui-text="Add one more facet to close tower?">false</param>
<param name="attachment_percentage" type="float" min="0" max="100" precision="1" appearance="full" gui-text="Length percentage of extra facet">100</param>
<label>------------------------------------------------------------</label>
<separator/>
</page>
<page name="mountains" gui-text="Mountain creases">
<param name="mountain_bool" type="bool" gui-text="Draw mountains?">true</param>
@ -84,8 +84,10 @@
<effect>
<object-type>all</object-type>
<effects-menu>
<submenu name="Origami Patterns">
<submenu name="Deprecated" />
<submenu name="FabLab Chemnitz Boxes/Papercraft">
<submenu name="Origami Patterns">
<submenu name="Deprecated" />
</submenu>
</submenu>
</effects-menu>
</effect>

View File

@ -14,7 +14,7 @@
</param>
<param name="ratio" type="float" min="0" max="1" precision="3" gui-text="Opening ratio">0.4</param>
<param name="rings" type="int" min="3" max="100" gui-text="Number of rings">15</param>
<label>------------------------------</label>
<separator/>
<param name="simulation_mode" type="bool" gui-text="Simulation mode">true</param>
<label>To simulate with OrigamiSimulator, semicreases (or facet creases) must be added to properly simulate paper, and the circles must be approximated as polygons.</label>
<param name="sides" type="int" min="10" max="100" gui-text="Number of sides for polygon approximating half circle">20</param>
@ -67,8 +67,10 @@
<effect>
<object-type>all</object-type>
<effects-menu>
<submenu name="Origami Patterns">
<submenu name="Pleat folds" />
<submenu name="FabLab Chemnitz Boxes/Papercraft">
<submenu name="Origami Patterns">
<submenu name="Pleat folds" />
</submenu>
</submenu>
</effects-menu>
</effect>

View File

@ -71,8 +71,10 @@
<effect>
<object-type>all</object-type>
<effects-menu>
<submenu name="Origami Patterns">
<submenu name="Pleat folds" />
<submenu name="FabLab Chemnitz Boxes/Papercraft">
<submenu name="Origami Patterns">
<submenu name="Pleat folds" />
</submenu>
</submenu>
</effects-menu>
</effect>

View File

@ -61,8 +61,10 @@
<effect>
<object-type>all</object-type>
<effects-menu>
<submenu name="Origami Patterns">
<submenu name="* Template submenu" />
<submenu name="FabLab Chemnitz Boxes/Papercraft">
<submenu name="Origami Patterns">
<submenu name="Template submenu" />
</submenu>
</submenu>
</effects-menu>
</effect>

View File

@ -13,10 +13,10 @@
<option value="magic_ball">Magic ball</option>
</param>
<param name="phase_shift" type="bool" gui-text="Shift phase?">false</param>
<label>------------------------------</label>
<separator/>
<param name="lines" type="int" min="1" max="100" gui-text="Number of lines">8</param>
<param name="columns" type="int" min="1" max="100" gui-text="Number of columns">16</param>
<label>------------------------------</label>
<separator/>
<param name="length" type="float" max="10000" precision="3" gui-text="Length of grid square">10.0</param>
<param name="units" type="optiongroup" appearance="combo" gui-text="Units">
<option value="mm">mm</option>
@ -68,7 +68,9 @@ The Magic ball is a different design that inverts both the upper half of the fir
<effect>
<object-type>all</object-type>
<effects-menu>
<submenu name="Origami Patterns" />
<submenu name="FabLab Chemnitz Boxes/Papercraft">
<submenu name="Origami Patterns"/>
</submenu>
</effects-menu>
</effect>
<script>

View File

@ -53,7 +53,7 @@ What do we want to check?
* then, when doing intersections, remove the `boundary`
from the intersection set, because two adjacent
segments from a subpath always intersect in their boundary
* handle the commands M, Z, L, C, Q, A (parsed via simplepath)
* handle the commands M, Z, L, C, Q, A
* M: moveto
* Z: closepath (straight closing line)
* L: lineto

View File

@ -88,7 +88,7 @@ def addPath(newList, refnode):
return ele
def reformatList( listOfPaths):
""" Returns a SVG paths list (same format as simplepath.parsePath) from a list of Path objects
""" Returns a SVG paths list from a list of Path objects
- Segments in paths are added in the new list
- simple Path are retrieved from the original refSVGPathList and put in the new list (thus preserving original bezier curves)
"""

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
'''
shapes_1.py
@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
updated for inkscape 1.0
'''
import os, sys, tempfile, webbrowser, math, inkex, simplestyle, simpletransform
import os, sys, tempfile, webbrowser, math, inkex
from lxml import etree
def info(s, newLine="\n"):

View File

@ -1,54 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<name>Custom Stroke Font - Edit Stroke Font</name>
<id>fablabchemnitz.de.stroke_font_creator.edit_stroke_font</id>
<param name="tab" type="notebook">
<page name="editStrokeFont" gui-text="Edit Stroke Font">
<param name="fontName" type="optiongroup" appearance="combo" gui-text="Font:">
<option value="Custom-Script">Custom-Script</option>
<option value="Custom-Square Italic">Custom-Square Italic</option>
<option value="Custom-Square Normal">Custom-Square Normal</option>
<option value="Hershey-Astrology">Hershey-Astrology</option>
<option value="Hershey-Cyrillic">Hershey-Cyrillic</option>
<option value="Hershey-Gothic English">Hershey-Gothic English</option>
<option value="Hershey-Gothic German">Hershey-Gothic German</option>
<option value="Hershey-Gothic Italian">Hershey-Gothic Italian</option>
<option value="Hershey-Greek 1-stroke">Hershey-Greek 1-stroke</option>
<option value="Hershey-Greek medium">Hershey-Greek medium</option>
<option value="Hershey-Japanese">Hershey-Japanese</option>
<option value="Hershey-Markers">Hershey-Markers</option>
<option value="Hershey-Math (lower)">Hershey-Math (lower)</option>
<option value="Hershey-Math (upper)">Hershey-Math (upper)</option>
<option value="Hershey-Meteorology">Hershey-Meteorology</option>
<option value="Hershey-Music">Hershey-Music</option>
<option value="Hershey-Sans 1-stroke">Hershey-Sans 1-stroke</option>
<option value="Hershey-Sans bold">Hershey-Sans bold</option>
<option value="Hershey-Script 1-stroke">Hershey-Script 1-stroke</option>
<option value="Hershey-Script 1-stroke (alt)">Hershey-Script 1-stroke (alt)</option>
<option value="Hershey-Script medium">Hershey-Script medium</option>
<option value="Hershey-Serif bold">Hershey-Serif bold</option>
<option value="Hershey-Serif bold italic">Hershey-Serif bold italic</option>
<option value="Hershey-Serif medium">Hershey-Serif medium</option>
<option value="Hershey-Serif medium italic">Hershey-Serif medium italic</option>
<option value="Hershey-Symbolic">Hershey-Symbolic</option>
</param>
<param name="rowCnt" type="int" min="1" max="999999" gui-text="No of Rows:">5</param>
<param name="fontSize" type="int" min="5" max="999999" gui-text="Font Size:">1000</param>
<label>This extension overwrites the current document</label>
</page>
<page name="desc" gui-text="Help">
<label xml:space="preserve">Inkscape extension for editing a stroke font.</label>
</page>
</param>
<effect>
<object-type>path</object-type>
<effects-menu>
<submenu name="FabLab Chemnitz">
<submenu name="Text"/>
</submenu>
</effects-menu>
</effect>
<script>
<command location="inx" interpreter="python">edit_stroke_font.py</command>
</script>
</inkscape-extension>

View File

@ -68,28 +68,6 @@ def transformedParsedPath(elem):
pp = getParsedPath(elem.get('d'))
return pp
# Following bloc takes care of the special condition where guides are transformed
# TODO: Make it working for 1.0
# ~ try:
# ~ transf = elem.get('transform')
# ~ mat = parseTransform(transf)
# ~ #pp format [['M',[x1,y1]],['L',[x2,y2]]]
# ~ for dElem in pp:
# ~ for i in range(1, len(dElem)):
# ~ param = dElem[i]
# ~ t1 = [[param[x], param[x+1]] for x in range(0, len(param), 2)]
# ~ for t1Elem in t1:
# ~ simpletransform.applyTransformToPoint(mat, t1Elem)
# ~ dElem[i] = [x for l in t1 for x in l]
# ~ elem.set('d', simplepath.formatPath(pp))
# ~ except:
# ~ #Don't break
# ~ pass
# ~ return pp
def updateFontData(strokeFontData, glyphPathElems, hGuides, lvGuides, rvGuides, rightOffsetType):
for elem in glyphPathElems:
char = elem.get(CommonDefs.idAttribName)

View File

@ -38,60 +38,3 @@
<option value="Hershey-Serif medium">Hershey-Serif medium</option>
<option value="Hershey-Serif medium italic">Hershey-Serif medium italic</option>
<option value="Hershey-Symbolic">Hershey-Symbolic</option>
<!-- ##! dynamically generated portion [end] -->
</param>
<param name="fontSize" type="float" min="1" max="999999" gui-text="Font Size:">20</param>
<param name="charSpacing" type="float" min="0" max="100" gui-text="Char Spacing:">1</param>
<param name="wordSpacing" type="float" min="0" max="100" gui-text="Word Spacing:">1</param>
<param name="lineSpacing" type="float" min="0" max="100" gui-text="Line Spacing:">1.5</param>
<param name="flowInBox" type="bool" gui-text="Flow Text in Selected Boxes:">true</param>
<param name="margin" type="float" min="-999999" max="999999" gui-text="Margin:">5</param>
<param name="hAlignment" type="optiongroup" appearance="combo" gui-text="Horizontal Alignment:">
<option value="left">Left</option>
<option value="right">Right</option>
<option value="center">Center</option>
<option value="justified">Justified</option>
</param>
<param name="vAlignment" type="optiongroup" appearance="combo" gui-text="Vertical Alignment:">
<option value="none">None</option>
<option value="top">Top</option>
<option value="bottom">Bottom</option>
<option value="center">Center</option>
</param>
<param name="expandDir" type="optiongroup" appearance="combo" gui-text="Create Extended Rectangles:">
<option value="none">None</option>
<option value="x">Horizontal Direction</option>
<option value="y">Vertical Direction</option>
</param>
<param name="expandDist" type="float" min="0" max="100" gui-text="Extended Rectangle Offset:">1</param>
</page>
<page name="info" gui-text="Help">
<label xml:space="preserve">This extension renders given text using the selected stroke font.
Action can be one of the following:
- 'Render the text' renders the text from the Text input box
(Use \n in the input string to start a new line of text)
- 'Render text from file' renders the text from the file specified in the Text File input box
- 'Render font glyph table' displays all the available glyphs of the given font
along with the license information
If the 'Flow Text in Selected Boxes' option is selected, the text is fit into the selected rectangle objects with
specified margin and justification. The rectangles are filled in their z order. If a single word cannot fit within the
given width, it's broken into smaller components.
If there are errors, please ensure the font data files exist in the strokefontdata folder and
the font list is synchronized.</label>
</page>
</param>
<effect needs-live-preview="true" needs-document="true">
<object-type>all</object-type>
<effects-menu>
<submenu name="FabLab Chemnitz">
<submenu name="Text"/>
</submenu>
</effects-menu>
</effect>
<script>
<command location="inx" interpreter="python">render_stroke_font_text.py</command>
</script>
</inkscape-extension>

View File

@ -24,33 +24,16 @@ import sys, os, fileinput, re, locale
from inkex import errormsg, addNS, NSS
from xml.dom.minidom import parse, Document
from math import ceil
# TODO: Find inkscape version
try:
from lxml import etree
from inkex import Style, Boolean
from inkex.paths import Path, CubicSuperPath, Transform
from inkex import bezier
ver = 1.0
except:
from inkex import etree
import simplestyle, cubicsuperpath, simplepath, simpletransform
from cubicsuperpath import CubicSuperPath
ver = 0.92
try:
from simpletransform import computePointInNode
oldVersion = False
except:
oldVersion = True # older than 0.92
from lxml import etree
from inkex import Style, Boolean
from inkex.paths import Path, CubicSuperPath, Transform
from inkex import bezier
# sys path already includes the module folder
from stroke_font_manager import CharData, getFontNames, xAscent, \
xDescent, xCapHeight, xXHeight, xSpaceROff, xFontId, xSize
class CommonDefs:
inkVer = ver
pyVer = sys.version_info.major
# inx filed that have the font list to be synchronized
inxFilesWithDynFont = ['render_stroke_font_text.inx', 'edit_stroke_font.inx']
@ -68,10 +51,6 @@ class CommonDefs:
if(encoding == 'cp0' or encoding is None):
encoding = locale.getpreferredencoding()
######### Function variants for 1.0 and 0.92 - Start ##########
# Used only in 0.92
def getPartsFromCubicSuper(csp):
parts = []
for subpath in csp:
@ -86,131 +65,70 @@ def getPartsFromCubicSuper(csp):
return parts
def formatStyle(styleStr):
if(CommonDefs.inkVer == 1.0):
return str(Style(styleStr))
else:
return simplestyle.formatStyle(styleStr)
return str(Style(styleStr))
def getCubicSuperPath(d = None):
if(CommonDefs.inkVer == 1.0):
if(d == None): return CubicSuperPath([])
return CubicSuperPath(Path(d).to_superpath())
else:
if(d == None): return []
return CubicSuperPath(simplepath.parsePath(d))
if(d == None): return CubicSuperPath([])
return CubicSuperPath(Path(d).to_superpath())
def getCubicLength(csp):
if(CommonDefs.inkVer == 1.0):
return bezier.csplength(csp)[1]
else:
parts = getPartsFromCubicSuper(cspath)
curveLen = 0
for i, part in enumerate(parts):
for j, seg in enumerate(part):
curveLen += bezmisc.bezierlengthSimpson((seg[0], seg[1], seg[2], seg[3]), \
tolerance = tolerance)
return curveLen
return bezier.csplength(csp)[1]
def getCubicBoundingBox(csp):
if(CommonDefs.inkVer == 1.0):
bbox = csp.to_path().bounding_box()
return bbox.left, bbox.right, bbox.top, bbox.bottom
else:
return simpletransform.refinedBBox(csp)
bbox = csp.to_path().bounding_box()
return bbox.left, bbox.right, bbox.top, bbox.bottom
def formatSuperPath(csp):
if(CommonDefs.inkVer == 1.0):
return csp.__str__()
else:
return cubicsuperpath.formatPath(csp)
return csp.__str__()
def getParsedPath(d):
if(CommonDefs.inkVer == 1.0):
# Copied from Path.to_arrays for compatibility
return [[seg.letter, list(seg.args)] for seg in Path(d).to_absolute()]
else:
return simplepath.parsePath(d)
return [[seg.letter, list(seg.args)] for seg in Path(d).to_absolute()]
def applyTransform(mat, csp):
if(CommonDefs.inkVer == 1.0):
csp.transform(mat)
else:
simpletransform.applyTransformToPath(mat, csp)
csp.transform(mat)
def getTranslatedPath(d, posX, posY):
if(CommonDefs.inkVer == 1.0):
path = Path(d)
path.translate(posX, posY, inplace = True)
return path.to_superpath().__str__()
else:
path = simplepath.parsePath(d)
simplepath.translatePath(path, posX, posY)
return simplepath.formatPath(path)
path = Path(d)
path.translate(posX, posY, inplace = True)
return path.to_superpath().__str__()
def getTransformMat(matAttr):
if(CommonDefs.inkVer == 1.0):
return Transform(matAttr)
else:
return simpletransform.parseTransform(matAttr)
return Transform(matAttr)
def getCurrentLayer(effect):
if(CommonDefs.inkVer == 1.0):
return effect.svg.get_current_layer()
else:
return effect.current_layer
return effect.svg.get_current_layer()
def getViewCenter(effect):
if(CommonDefs.inkVer == 1.0):
return effect.svg.namedview.center
else:
return effect.view_center
return effect.svg.namedview.center
def computePtInNode(vc, layer):
if(CommonDefs.inkVer == 1.0):
# ~ return (-Transform(layer.transform * mat)).apply_to_point(vc)
return (-layer.transform).apply_to_point(vc)
else:
if(oldVersion):
return list(vc)
else:
return computePointInNode(list(vc), layer)
return (-layer.transform).apply_to_point(vc)
def getSelectedElements(effect):
if(CommonDefs.inkVer == 1.0):
return effect.svg.selected
else:
return effect.selected
return effect.svg.selected
def getEtree():
return etree
def getAddFnTypes(effect):
if(CommonDefs.inkVer == 1.0):
addFn = effect.arg_parser.add_argument
typeFloat = float
typeInt = int
typeString = str
typeBool = Boolean
else:
addFn = effect.OptionParser.add_option
typeFloat = 'float'
typeInt = 'int'
typeString = 'string'
typeBool = 'inkbool'
addFn = effect.arg_parser.add_argument
typeFloat = float
typeInt = int
typeString = str
typeBool = Boolean
return addFn, typeFloat, typeInt, typeString, typeBool
def runEffect(effect):
if(CommonDefs.inkVer == 1.0): effect.run()
else: effect.affect()
effect.run()
######### Function variants for 1.0 and 0.92 - End ##########
def getDecodedChars(chars):
if(CommonDefs.pyVer == 2):
return chars.decode(CommonDefs.encoding)
else: #if?
return chars
return chars
def indentStr(cnt):
ostr = ''
@ -238,21 +156,14 @@ def syncFontList(extPath):
for line in fileinput.input(xf, inplace = True):
if sectMarker in line:
if(sectMarkerLine != None):
if(CommonDefs.pyVer == 3):
# For some reasons python2 giving syntax error without eval
eval("print(getXMLItemsStr(sectMarkerLine, sectMarker, fontNames), end = '')")
else:
print(getXMLItemsStr(sectMarkerLine, sectMarker, fontNames)),
eval("print(getXMLItemsStr(sectMarkerLine, sectMarker, fontNames), end = '')")
sectMarkerLine = None
else:
sectMarkerLine = line
else:
if(sectMarkerLine == None):
if(CommonDefs.pyVer == 3):
eval("print(line, end = '')")
else:
print(line),
eval("print(line, end = '')")
except Exception as e:
errormsg('Error updating font list...\n' + str(e))
@ -316,16 +227,14 @@ def createTempl(callback, effect, extraInfo, rowCnt, glyphCnt, \
currLayers = svg.xpath('//svg:g', namespaces = NSS)
for layer in currLayers:
# Note: getparent()
parentLayer = layer.getparent() if(CommonDefs.inkVer == 1.0) \
else effect.getParentNode(layer)
parentLayer = layer.getparent()
if(parentLayer != None):
parentLayer.remove(layer)
currExtraElems = svg.xpath('//svg:' + CommonDefs.fontOtherInfo, namespaces = NSS)
for elem in currExtraElems:
parentElem = elem.getparent() if(CommonDefs.inkVer == 1.0) \
else effect.getParentNode(elem)
parentElem = elem.getparent()
parentElem.remove(elem)
extraInfoElem = etree.SubElement(svg, CommonDefs.fontOtherInfo)
@ -352,7 +261,7 @@ def createTempl(callback, effect, extraInfo, rowCnt, glyphCnt, \
editLayer.set(addNS('label', 'inkscape'), 'Glyphs')
editLayer.set(addNS('groupmode', 'inkscape'), 'layer')
editLayer.set('id', 'glyph')#TODO: How to make this dynamic?
view = svg.namedview if CommonDefs.inkVer == 1.0 else effect.getNamedView()
view = svg.namedview
view.set(addNS('current-layer', 'inkscape'), editLayer.get('id'))
for row in range(0, rowCnt):

View File

@ -1,4 +1,4 @@
#! /usr/bin/env python
#! /usr/bin/env python3
import warnings
import sys
@ -9,8 +9,6 @@ import subprocess
import tempfile
import shutil
import copy
from simplestyle import *
from copy import deepcopy
from io import BytesIO
from lxml import etree