From 47048e6f01ed1d96fd1a3831cadb467df58182c0 Mon Sep 17 00:00:00 2001 From: Mario Voigt Date: Sun, 31 Mar 2024 23:33:36 +0200 Subject: [PATCH] various small bug fixes and newest updates --- README.md | 2 +- .../apply_transformations.py | 10 ++------ .../box_maker_generic_generator.py | 6 +++-- .../fablabchemnitz/dxf2papercraft/meta.json | 2 +- .../label_guides/label_guides.py | 4 +-- .../open_in_roland_cutstudio.py | 25 ++++++++----------- extensions/fablabchemnitz/pixel2svg/meta.json | 2 +- .../raster_perspective/raster_perspective.py | 7 +++--- extensions/fablabchemnitz/shapes/meta.json | 4 +-- .../fablabchemnitz/sine_and_lace/meta.json | 22 ++++++++-------- .../render_stroke_font_text.inx | 1 + .../render_stroke_font_text.py | 5 +++- extensions/fablabchemnitz/sudoku/meta.json | 22 ++++++++-------- .../svg2shenzhen/svg2shenzhen/export.py | 10 ++++---- 14 files changed, 60 insertions(+), 62 deletions(-) diff --git a/README.md b/README.md index ee9b9f1..3267321 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ -In short: A maintained extension collection for Inkscape 1.2, working on Windows and Linux. There are **237 extension folders** with **432 .inx files** inside. We also take part at https://inkscape.org/gallery/=extension/ (with single extension uploads). +In short: A maintained extension collection for Inkscape 1.2, working on Windows and Linux. There are **239 extension folders** with **459 .inx files** inside. We also take part at https://inkscape.org/gallery/=extension/ (with single extension uploads). # About MightyScape diff --git a/extensions/fablabchemnitz/apply_transformations/apply_transformations.py b/extensions/fablabchemnitz/apply_transformations/apply_transformations.py index e864953..9290d77 100644 --- a/extensions/fablabchemnitz/apply_transformations/apply_transformations.py +++ b/extensions/fablabchemnitz/apply_transformations/apply_transformations.py @@ -141,10 +141,7 @@ class ApplyTransformations(inkex.EffectExtension): or not isequal(newxy2[0], newxy3[0]) or not isequal(newxy1[1], newxy2[1]) ): - inkex.utils.errormsg( - "Warning: Shape %s (%s) is approximate only, try Object to path first for better results" - % (element.TAG, element.get("id")) - ) + inkex.utils.errormsg(f"Warning: Shape {node.TAG} ({node.get('id')}) is approximate only, try Object to path first for better results") if element.TAG == "ellipse": element.set("rx", edgex / 2) @@ -204,10 +201,7 @@ class ApplyTransformations(inkex.EffectExtension): inkex.addNS('text', 'svg'), inkex.addNS('image', 'svg')]: element.attrib['transform'] = str(transf) - inkex.utils.errormsg( - "Shape %s (%s) not yet supported. Not all transforms will be applied. Try Object to path first" - % (element.TAG, element.get("id")) - ) + inkex.utils.errormsg(f"Shape {node.TAG} ({node.get('id')}) not yet supported. Not all transforms will be applied. Try Object to path first") else: # e.g. self.scaleStrokeWidth(element, transf) diff --git a/extensions/fablabchemnitz/box_maker_generic_generator/box_maker_generic_generator.py b/extensions/fablabchemnitz/box_maker_generic_generator/box_maker_generic_generator.py index 1f7a5af..f976612 100644 --- a/extensions/fablabchemnitz/box_maker_generic_generator/box_maker_generic_generator.py +++ b/extensions/fablabchemnitz/box_maker_generic_generator/box_maker_generic_generator.py @@ -1540,7 +1540,8 @@ class BoxFace: InteriorHeight = self.bottom_right_corner.y_end_joint * Height_percentage / 100.0 l_NotchLine = NotchLine((0, 0, 1), (InteriorHeight, 0, 1), math.pi/2, z_joint_size) - StartHole = l_NotchLine.start_line_joint_y + l_NotchLine.JointSize + #First hole z computation. Start at notch line but add delta if Height_percentage is not 100% + StartHole = l_NotchLine.start_line_joint_y + l_NotchLine.JointSize + self.bottom_right_corner.y_end_joint - InteriorHeight Spacing = 2*l_NotchLine.JointSize DebugMsg("drawFaceWithHoles, Hole Start ="+str(StartHole)+" Spacing="+str(Spacing)+" n_holes"+str(l_NotchLine.nb_finger_joint//2) +' n_slot='+str(n_slot)+' slot_size='+str(slot_size)+" Delta_Pos="+str(DeltaHolePosition)+'\n') @@ -1548,7 +1549,8 @@ class BoxFace: #For each wall, draw holes corresponding at each notch on zbox for j in range(int(l_NotchLine.nb_finger_joint//2)): drawHole(self.path, i*(slot_size+thickness) - DeltaHolePosition -thickness, StartHole + j*Spacing, thickness, l_NotchLine.JointSize, burn) - + DebugMsg("drawHole, Slot="+str(i)+", j="+str(j)+", x="+str(i*(slot_size+thickness) - DeltaHolePosition -thickness)+" y="+str(StartHole + j*Spacing)+'\n') + #Close the path if asked if ClosePath: self.path.Close() diff --git a/extensions/fablabchemnitz/dxf2papercraft/meta.json b/extensions/fablabchemnitz/dxf2papercraft/meta.json index 23df6d3..12715fb 100644 --- a/extensions/fablabchemnitz/dxf2papercraft/meta.json +++ b/extensions/fablabchemnitz/dxf2papercraft/meta.json @@ -10,7 +10,7 @@ "license_url": "https://sourceforge.net/projects/dxf2papercraft/files/dxf2papercraft_v0.2.tgz/download", "comment": "Written by Mario Voigt", "source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.2/src/branch/master/extensions/fablabchemnitz/dxf2papercraft", - "fork_url": "", + "fork_url": null, "documentation_url": "https://stadtfabrikanten.org/display/IFM/DXF+2+Papercraft", "inkscape_gallery_url": "https://inkscape.org/~MarioVoigt/%E2%98%85dxf2papercraft", "contributors": [ diff --git a/extensions/fablabchemnitz/label_guides/label_guides.py b/extensions/fablabchemnitz/label_guides/label_guides.py index 9192110..e28fa8c 100644 --- a/extensions/fablabchemnitz/label_guides/label_guides.py +++ b/extensions/fablabchemnitz/label_guides/label_guides.py @@ -428,7 +428,7 @@ class LabelGuides(inkex.Effect): # Draw horizontal guides for g in guides['h']: - add_SVG_guide(0, self.svg.viewport_height - g, 'horz', colour, nv) + add_SVG_guide(0, self.svg.viewbox_height - g, 'horz', colour, nv) def _draw_centre_guides(self, document, label_opts, colour): """ @@ -444,7 +444,7 @@ class LabelGuides(inkex.Effect): for g in range(0, len(guides['h']), 2): pos = (guides['h'][g] + guides['h'][g + 1]) / 2 - add_SVG_guide(0, self.svg.viewport_height - pos, 'horz', colour, nv) + add_SVG_guide(0, self.svg.viewbox_height - pos, 'horz', colour, nv) def _draw_shapes(self, document, label_opts, inset): """ diff --git a/extensions/fablabchemnitz/open_in_roland_cutstudio/open_in_roland_cutstudio.py b/extensions/fablabchemnitz/open_in_roland_cutstudio/open_in_roland_cutstudio.py index 3cbbecd..179e0c3 100644 --- a/extensions/fablabchemnitz/open_in_roland_cutstudio/open_in_roland_cutstudio.py +++ b/extensions/fablabchemnitz/open_in_roland_cutstudio/open_in_roland_cutstudio.py @@ -22,14 +22,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ''' -# The source code is a horrible mess. I apologize for your inconvenience, but hope that it still helps. Feel free to improve :-) -# Keep everything python2 compatible as long as people out there are using Inkscape <= 0.92.4! - -from __future__ import division -from __future__ import print_function -from __future__ import unicode_literals -from __future__ import absolute_import - from builtins import open from builtins import map from builtins import str @@ -57,6 +49,11 @@ import string DEVNULL = open(os.devnull, 'w') atexit.register(DEVNULL.close) +# work around Inkscape 1.3 failing to start when it "calls itself" (Inkscape -> Extension -> Inkscape): +# https://gitlab.com/inkscape/inkscape/-/issues/4163 +# https://gitlab.com/inkscape/extensions/-/merge_requests/534 +# TODO: Rewrite most parts of this extension using the inkex python module. This removes the need for such workarounds. +os.environ["SELF_CALL"] = "true" def message(s): sys.stderr.write(s+"\n") @@ -71,9 +68,9 @@ def which(program, raiseError, extraPaths=[], subdir=None): """ pathlist=os.environ["PATH"].split(os.pathsep) if "nt" in os.name: - pathlist.append(os.environ.get("ProgramFiles","C:\Program Files\\")) - pathlist.append(os.environ.get("ProgramFiles(x86)","C:\Program Files (x86)\\")) - pathlist.append("C:\Program Files\\") # needed for 64bit inkscape on 64bit Win7 machines + pathlist.append(os.environ.get('ProgramFiles','C:\\Program Files\\')) + pathlist.append(os.environ.get('ProgramFiles(x86)','C:\\Program Files (x86)\\')) + pathlist.append('C:\\Program Files\\') # needed for 64bit inkscape on 64bit Win7 machines pathlist.append(os.path.dirname(os.path.dirname(os.getcwd()))) # portable application in the current directory pathlist += extraPaths if subdir: @@ -286,8 +283,8 @@ def EPS2CutstudioEPS(src, dest, mirror=False): m=m.transpose() #debug("with {}".format(m)) pnew = numpy.matmul(m, p) - x=float(pnew[0]) - y=float(pnew[1]) + x=float(pnew.item(0)) + y=float(pnew.item(1)) #debug("to: {} {}".format(x, y)) return [x, y] def outputMoveto(x, y): @@ -410,7 +407,7 @@ if "--selftest" in sys.argv: if os.name=="nt": DETACHED_PROCESS = 8 # start as "daemon" - Popen([which("CutStudio\CutStudio.exe", True), "/import", destination], creationflags=DETACHED_PROCESS, close_fds=True) + Popen([which("CutStudio\\CutStudio.exe", True), "/import", destination], creationflags=DETACHED_PROCESS, close_fds=True) else: #check if we have access to "wine" CUTSTUDIO_C_DRIVE = str(Path.home()) + "/.wine/drive_c/" CUTSTUDIO_PATH_LINUX_WINE = CUTSTUDIO_C_DRIVE + "Program Files (x86)/CutStudio/CutStudio.exe" diff --git a/extensions/fablabchemnitz/pixel2svg/meta.json b/extensions/fablabchemnitz/pixel2svg/meta.json index effffef..537edc5 100644 --- a/extensions/fablabchemnitz/pixel2svg/meta.json +++ b/extensions/fablabchemnitz/pixel2svg/meta.json @@ -10,7 +10,7 @@ "license_url": "https://gitlab.com/su-v/inx-pixel2svg/-/blob/master/COPYING", "comment": "ported to Inkscape v1 manually by Mario Voigt", "source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.2/src/branch/master/extensions/fablabchemnitz/pixel2svg", - "fork_url": "ttps://gitlab.com/su-v/inx-pixel2svg", + "fork_url": "https://gitlab.com/su-v/inx-pixel2svg", "documentation_url": "https://stadtfabrikanten.org/display/IFM/Pixel2SVG", "inkscape_gallery_url": null, "contributors": [ diff --git a/extensions/fablabchemnitz/raster_perspective/raster_perspective.py b/extensions/fablabchemnitz/raster_perspective/raster_perspective.py index 95c223d..d1776e9 100644 --- a/extensions/fablabchemnitz/raster_perspective/raster_perspective.py +++ b/extensions/fablabchemnitz/raster_perspective/raster_perspective.py @@ -80,9 +80,10 @@ class RasterPerspective(inkex.Effect): if str(envelope_node) == "image" and str(the_image_node) == "path": envelope_node, the_image_node = self.svg.selection #switch - if str(the_image_node) != "image" and str(envelope_node) != "path": - inkex.utils.debug(WARN) - return + if str(the_image_node) != "image" or str(envelope_node) != "path": + inkex.errormsg(WARN) + exit() + img_width, img_height = the_image_node.width, the_image_node.height try: diff --git a/extensions/fablabchemnitz/shapes/meta.json b/extensions/fablabchemnitz/shapes/meta.json index 3b19d6e..5088b76 100644 --- a/extensions/fablabchemnitz/shapes/meta.json +++ b/extensions/fablabchemnitz/shapes/meta.json @@ -7,10 +7,10 @@ "original_name": "Shapes for 1.0", "original_id": "org.inkscape.effect.shapes1", "license": "GNU GPL v2", - "license_url": "https://www.arakne.es/wp-content/uploads/2017/08/arakne_shapes_1.zip", + "license_url": "https://www.arakne.es/inkscape-shapes-nueva-version-compatible-con-inkscape-1-2", "comment": "", "source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.2/src/branch/master/extensions/fablabchemnitz/shapes", - "fork_url": "https://www.arakne.es/en/inkscape-1-0-shapes-extension-new-version/", + "fork_url": "https://www.arakne.es/inkscape-shapes-nueva-version-compatible-con-inkscape-1-2", "documentation_url": "https://stadtfabrikanten.org/display/IFM/Shapes", "inkscape_gallery_url": null, "contributors": [ diff --git a/extensions/fablabchemnitz/sine_and_lace/meta.json b/extensions/fablabchemnitz/sine_and_lace/meta.json index 782d6c3..f188952 100644 --- a/extensions/fablabchemnitz/sine_and_lace/meta.json +++ b/extensions/fablabchemnitz/sine_and_lace/meta.json @@ -1,20 +1,20 @@ [ { - "name": "Slic3r STL Input", - "id": "fablabchemnitz.de.slic3r_stl_input", - "path": "slic3r_stl_input", + "name": "Sine And Lace", + "id": "fablabchemnitz.de.sine_and_lace", + "path": "sine_and_lace", "dependent_extensions": null, - "original_name": "STL Input", - "original_id": "com.github.jnweiger.inkscape.input.stl", - "license": "GNU GPL v2", - "license_url": "https://github.com/jnweiger/inkscape-input-stl/blob/master/LICENSE", + "original_name": "Sine and Lace", + "original_id": "command.experiment.sineandlace", + "license": "GNU GPL v3", + "license_url": "https://github.com/evil-mad/EggBot/blob/master/LICENSE", "comment": "", - "source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.2/src/branch/master/extensions/fablabchemnitz/slic3r_stl_input", - "fork_url": "https://github.com/jnweiger/inkscape-input-stl", - "documentation_url": "https://stadtfabrikanten.org/display/IFM/Slic3r+STL+Input", + "source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.2/src/branch/master/extensions/fablabchemnitz/sine_and_lace", + "fork_url": "https://github.com/evil-mad/EggBot", + "documentation_url": "https://stadtfabrikanten.org/display/IFM/Sine+And+Lace", "inkscape_gallery_url": null, "contributors": [ - "github.com/jnweiger", + "github.com/evil-mad", "github.com/eridur-de" ] } diff --git a/extensions/fablabchemnitz/stroke_font_creator/render_stroke_font_text.inx b/extensions/fablabchemnitz/stroke_font_creator/render_stroke_font_text.inx index 8940d0d..91eb2af 100644 --- a/extensions/fablabchemnitz/stroke_font_creator/render_stroke_font_text.inx +++ b/extensions/fablabchemnitz/stroke_font_creator/render_stroke_font_text.inx @@ -44,6 +44,7 @@ 1 1 1.5 + 1 true 5 diff --git a/extensions/fablabchemnitz/stroke_font_creator/render_stroke_font_text.py b/extensions/fablabchemnitz/stroke_font_creator/render_stroke_font_text.py index 4c6dca5..536a8f5 100644 --- a/extensions/fablabchemnitz/stroke_font_creator/render_stroke_font_text.py +++ b/extensions/fablabchemnitz/stroke_font_creator/render_stroke_font_text.py @@ -150,6 +150,9 @@ class RenderStrokeFontText(Effect): addFn('--lineSpacing', action = 'store', type = typeFloat, dest = 'lineSpacing', \ default = '1.5', help = 'Spacing between the lines') + addFn('--strokeWidthMult', action = 'store', type = typeFloat, dest = 'strokeWidthMult', \ + default = '1', help = 'Stroke Width Proportion') + addFn('--flowInBox', action = 'store', type = typeBool, dest = 'flowInBox', \ default = False, help = 'Fit the text in the selected rectangle objects') @@ -196,7 +199,7 @@ class RenderStrokeFontText(Effect): extPath = os.path.dirname(os.path.abspath(__file__)) - strokeWidth = 0.02 * fontSize + strokeWidth = 0.02 * fontSize * strokeWidthMult layer = getCurrentLayer(self) renderer = InkscapeFontRenderer(layer, getViewCenter(self), strokeWidth) diff --git a/extensions/fablabchemnitz/sudoku/meta.json b/extensions/fablabchemnitz/sudoku/meta.json index d716ff4..730b777 100644 --- a/extensions/fablabchemnitz/sudoku/meta.json +++ b/extensions/fablabchemnitz/sudoku/meta.json @@ -1,20 +1,20 @@ [ { - "name": "Sundial Declining", - "id": "fablabchemnitz.de.sundial_declining", - "path": "sundial_declining", + "name": "Sudoku", + "id": "fablabchemnitz.de.sudoku", + "path": "sudoku", "dependent_extensions": null, - "original_name": "Sundial", - "original_id": "fr.electropol.tableausimple.inkscape", - "license": "Public Domain", - "license_url": "https://inkscape.org/de/~TomasUrban/%E2%98%85sundial-declining", + "original_name": "Sudoku", + "original_id": "org.inkscape.render.sudoku", + "license": "GNU GPL v3", + "license_url": "https://github.com/neocogent/inkscape-sudoku/blob/master/LICENCE", "comment": "ported to Inkscape v1 by Mario Voigt", - "source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.2/src/branch/master/extensions/fablabchemnitz/sundial_declining", - "fork_url": "https://inkscape.org/de/~TomasUrban/%E2%98%85sundial-declining", - "documentation_url": "https://stadtfabrikanten.org/display/IFM/Sundial+Declining", + "source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.2/src/branch/master/extensions/fablabchemnitz/sudoku", + "fork_url": "https://github.com/neocogent/inkscape-sudoku", + "documentation_url": "https://stadtfabrikanten.org/display/IFM/Sudoku", "inkscape_gallery_url": null, "contributors": [ - "inkscape.org/TomasUrban", + "github.com/neocogent", "github.com/eridur-de" ] } diff --git a/extensions/fablabchemnitz/svg2shenzhen/svg2shenzhen/export.py b/extensions/fablabchemnitz/svg2shenzhen/svg2shenzhen/export.py index 39fc79a..deb7022 100644 --- a/extensions/fablabchemnitz/svg2shenzhen/svg2shenzhen/export.py +++ b/extensions/fablabchemnitz/svg2shenzhen/svg2shenzhen/export.py @@ -15,7 +15,7 @@ from copy import deepcopy from inkex import bezier from inkex.transforms import Transform from pathlib import Path - +import re homePath = str() homePath = Path.home() @@ -276,8 +276,8 @@ class Svg2ShenzhenExport(inkex.Effect): def setInkscapeScaling(self): root = self.document.getroot() - height = float(root.get('height').replace("mm", "")) - width = float(root.get('width').replace("mm", "")) + height = float(re.sub(r'[a-zA-Z]+', "", root.get('height'))) + width = float(re.sub(r'[a-zA-Z]+', "", root.get('width'))) self.doc_width = width self.doc_height = height @@ -293,8 +293,8 @@ class Svg2ShenzhenExport(inkex.Effect): def setDocumentSquare(self): root = self.document.getroot() - height = float(root.attrib['height'].replace("mm", "")) - width = float(root.attrib['width'].replace("mm", "")) + height = float(re.sub(r'[a-zA-Z]+', "", root.attrib['height'])) + width = float(re.sub(r'[a-zA-Z]+', "", root.attrib['width'])) if (width > height): root.attrib['height'] = str(width) + "mm"