2020-04-20 18:52:50 +00:00
|
|
|
import logging
|
2018-10-24 00:08:46 +00:00
|
|
|
import os
|
2018-04-29 01:26:53 +00:00
|
|
|
import sys
|
|
|
|
import traceback
|
|
|
|
from argparse import ArgumentParser
|
2021-03-04 17:40:53 +00:00
|
|
|
from io import StringIO
|
|
|
|
|
|
|
|
from inkex import errormsg
|
|
|
|
from lxml.etree import XMLSyntaxError
|
2018-10-24 00:08:46 +00:00
|
|
|
|
2019-03-28 18:47:05 +00:00
|
|
|
import lib.debug as debug
|
2020-04-20 18:52:50 +00:00
|
|
|
from lib import extensions
|
|
|
|
from lib.i18n import _
|
2021-03-04 17:40:53 +00:00
|
|
|
from lib.utils import restore_stderr, save_stderr, version
|
2018-04-29 01:26:53 +00:00
|
|
|
|
2018-11-15 01:23:06 +00:00
|
|
|
logger = logging.getLogger('shapely.geos')
|
|
|
|
logger.setLevel(logging.DEBUG)
|
|
|
|
shapely_errors = StringIO()
|
|
|
|
ch = logging.StreamHandler(shapely_errors)
|
|
|
|
ch.setLevel(logging.DEBUG)
|
|
|
|
formatter = logging.Formatter('%(name)s - %(levelname)s - %(message)s')
|
|
|
|
ch.setFormatter(formatter)
|
|
|
|
logger.addHandler(ch)
|
|
|
|
|
|
|
|
|
2018-04-29 02:14:23 +00:00
|
|
|
parser = ArgumentParser()
|
|
|
|
parser.add_argument("--extension")
|
|
|
|
my_args, remaining_args = parser.parse_known_args()
|
2018-04-29 01:26:53 +00:00
|
|
|
|
2018-10-24 00:08:46 +00:00
|
|
|
if os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), "DEBUG")):
|
2019-03-28 18:47:05 +00:00
|
|
|
debug.enable()
|
2018-10-24 00:08:46 +00:00
|
|
|
|
2018-04-29 02:14:23 +00:00
|
|
|
extension_name = my_args.extension
|
2018-07-29 00:40:14 +00:00
|
|
|
|
|
|
|
# example: foo_bar_baz -> FooBarBaz
|
|
|
|
extension_class_name = extension_name.title().replace("_", "")
|
|
|
|
|
|
|
|
extension_class = getattr(extensions, extension_class_name)
|
2018-04-29 01:26:53 +00:00
|
|
|
extension = extension_class()
|
|
|
|
|
new extension: Auto-Route Satin Columns (#330)
**video demo:** https://www.youtube.com/watch?v=tbghtqziB1g
This branch adds a new extension, Auto-Route Satin Columns, implementing #214! This is a huge new feature that opens the door wide for exciting stuff like lettering (#142).
To use it, select some satin columns and run the extension. After a few seconds, it will replace your satins with a new set with a logical stitching order. Under-pathing and jump-stitches will be added as necessary, and satins will be broken to facilitate jumps. The resulting satins will retain all of the parameters you had set on the original satins, including underlay, zig-zag spacing, etc.
By default, it will choose the left-most extreme as the starting point and the right-most extreme as the ending point (even if these occur partway through a satin such as the left edge of a letter "o"). You can override this by attaching the new "Auto-route satin stitch starting/ending position" commands.
There's also an option to add trims instead of jump stitches. Any jump stitch over 1mm is trimmed. I might make this configurable in the future but in my tests it seems to do a good job. Trim commands are added to the SVG, so it's easy enough to modify/delete as you see fit.
2018-10-30 23:43:21 +00:00
|
|
|
if hasattr(sys, 'gettrace') and sys.gettrace():
|
2021-03-04 17:40:53 +00:00
|
|
|
extension.run(args=remaining_args)
|
2018-04-29 01:26:53 +00:00
|
|
|
else:
|
new extension: Auto-Route Satin Columns (#330)
**video demo:** https://www.youtube.com/watch?v=tbghtqziB1g
This branch adds a new extension, Auto-Route Satin Columns, implementing #214! This is a huge new feature that opens the door wide for exciting stuff like lettering (#142).
To use it, select some satin columns and run the extension. After a few seconds, it will replace your satins with a new set with a logical stitching order. Under-pathing and jump-stitches will be added as necessary, and satins will be broken to facilitate jumps. The resulting satins will retain all of the parameters you had set on the original satins, including underlay, zig-zag spacing, etc.
By default, it will choose the left-most extreme as the starting point and the right-most extreme as the ending point (even if these occur partway through a satin such as the left edge of a letter "o"). You can override this by attaching the new "Auto-route satin stitch starting/ending position" commands.
There's also an option to add trims instead of jump stitches. Any jump stitch over 1mm is trimmed. I might make this configurable in the future but in my tests it seems to do a good job. Trim commands are added to the SVG, so it's easy enough to modify/delete as you see fit.
2018-10-30 23:43:21 +00:00
|
|
|
save_stderr()
|
|
|
|
exception = None
|
|
|
|
try:
|
2021-03-04 17:40:53 +00:00
|
|
|
extension.run(args=remaining_args)
|
new extension: Auto-Route Satin Columns (#330)
**video demo:** https://www.youtube.com/watch?v=tbghtqziB1g
This branch adds a new extension, Auto-Route Satin Columns, implementing #214! This is a huge new feature that opens the door wide for exciting stuff like lettering (#142).
To use it, select some satin columns and run the extension. After a few seconds, it will replace your satins with a new set with a logical stitching order. Under-pathing and jump-stitches will be added as necessary, and satins will be broken to facilitate jumps. The resulting satins will retain all of the parameters you had set on the original satins, including underlay, zig-zag spacing, etc.
By default, it will choose the left-most extreme as the starting point and the right-most extreme as the ending point (even if these occur partway through a satin such as the left edge of a letter "o"). You can override this by attaching the new "Auto-route satin stitch starting/ending position" commands.
There's also an option to add trims instead of jump stitches. Any jump stitch over 1mm is trimmed. I might make this configurable in the future but in my tests it seems to do a good job. Trim commands are added to the SVG, so it's easy enough to modify/delete as you see fit.
2018-10-30 23:43:21 +00:00
|
|
|
except (SystemExit, KeyboardInterrupt):
|
|
|
|
raise
|
2021-03-04 17:40:53 +00:00
|
|
|
except XMLSyntaxError:
|
|
|
|
msg = _("Ink/Stitch cannot read your SVG file. "
|
|
|
|
"This is often the case when you use a file which has been created with Adobe Illustrator.")
|
|
|
|
msg += "\n\n"
|
|
|
|
msg += _("Try to import the file into Inkscape through 'File > Import...' (Ctrl+I)")
|
|
|
|
errormsg(msg)
|
new extension: Auto-Route Satin Columns (#330)
**video demo:** https://www.youtube.com/watch?v=tbghtqziB1g
This branch adds a new extension, Auto-Route Satin Columns, implementing #214! This is a huge new feature that opens the door wide for exciting stuff like lettering (#142).
To use it, select some satin columns and run the extension. After a few seconds, it will replace your satins with a new set with a logical stitching order. Under-pathing and jump-stitches will be added as necessary, and satins will be broken to facilitate jumps. The resulting satins will retain all of the parameters you had set on the original satins, including underlay, zig-zag spacing, etc.
By default, it will choose the left-most extreme as the starting point and the right-most extreme as the ending point (even if these occur partway through a satin such as the left edge of a letter "o"). You can override this by attaching the new "Auto-route satin stitch starting/ending position" commands.
There's also an option to add trims instead of jump stitches. Any jump stitch over 1mm is trimmed. I might make this configurable in the future but in my tests it seems to do a good job. Trim commands are added to the SVG, so it's easy enough to modify/delete as you see fit.
2018-10-30 23:43:21 +00:00
|
|
|
except Exception:
|
|
|
|
exception = traceback.format_exc()
|
|
|
|
finally:
|
|
|
|
restore_stderr()
|
|
|
|
|
|
|
|
if shapely_errors.tell():
|
2021-03-04 17:40:53 +00:00
|
|
|
errormsg(shapely_errors.getvalue())
|
new extension: Auto-Route Satin Columns (#330)
**video demo:** https://www.youtube.com/watch?v=tbghtqziB1g
This branch adds a new extension, Auto-Route Satin Columns, implementing #214! This is a huge new feature that opens the door wide for exciting stuff like lettering (#142).
To use it, select some satin columns and run the extension. After a few seconds, it will replace your satins with a new set with a logical stitching order. Under-pathing and jump-stitches will be added as necessary, and satins will be broken to facilitate jumps. The resulting satins will retain all of the parameters you had set on the original satins, including underlay, zig-zag spacing, etc.
By default, it will choose the left-most extreme as the starting point and the right-most extreme as the ending point (even if these occur partway through a satin such as the left edge of a letter "o"). You can override this by attaching the new "Auto-route satin stitch starting/ending position" commands.
There's also an option to add trims instead of jump stitches. Any jump stitch over 1mm is trimmed. I might make this configurable in the future but in my tests it seems to do a good job. Trim commands are added to the SVG, so it's easy enough to modify/delete as you see fit.
2018-10-30 23:43:21 +00:00
|
|
|
|
|
|
|
if exception:
|
2021-03-04 17:40:53 +00:00
|
|
|
errormsg(_("Ink/Stitch experienced an unexpected error.") + "\n")
|
|
|
|
errormsg(_("If you'd like to help, please file an issue at "
|
|
|
|
"https://github.com/inkstitch/inkstitch/issues "
|
|
|
|
"and include the entire error description below:") + "\n")
|
|
|
|
errormsg(version.get_inkstitch_version() + "\n")
|
|
|
|
errormsg(exception)
|
new extension: Auto-Route Satin Columns (#330)
**video demo:** https://www.youtube.com/watch?v=tbghtqziB1g
This branch adds a new extension, Auto-Route Satin Columns, implementing #214! This is a huge new feature that opens the door wide for exciting stuff like lettering (#142).
To use it, select some satin columns and run the extension. After a few seconds, it will replace your satins with a new set with a logical stitching order. Under-pathing and jump-stitches will be added as necessary, and satins will be broken to facilitate jumps. The resulting satins will retain all of the parameters you had set on the original satins, including underlay, zig-zag spacing, etc.
By default, it will choose the left-most extreme as the starting point and the right-most extreme as the ending point (even if these occur partway through a satin such as the left edge of a letter "o"). You can override this by attaching the new "Auto-route satin stitch starting/ending position" commands.
There's also an option to add trims instead of jump stitches. Any jump stitch over 1mm is trimmed. I might make this configurable in the future but in my tests it seems to do a good job. Trim commands are added to the SVG, so it's easy enough to modify/delete as you see fit.
2018-10-30 23:43:21 +00:00
|
|
|
sys.exit(1)
|
|
|
|
else:
|
|
|
|
sys.exit(0)
|