kopia lustrzana https://github.com/inkstitch/inkstitch
ignore empty d
rodzic
455b02847f
commit
2f27d6af16
|
|
@ -1,6 +1,7 @@
|
|||
from auto_fill import AutoFill
|
||||
from clone import Clone
|
||||
from element import EmbroideryElement
|
||||
from empty_d_object import EmptyDObject
|
||||
from fill import Fill
|
||||
from image import ImageObject
|
||||
from polyline import Polyline
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
from ..i18n import _
|
||||
from .element import EmbroideryElement
|
||||
from .validation import ObjectTypeWarning
|
||||
|
||||
|
||||
class EmptyD(ObjectTypeWarning):
|
||||
name = _("Empty D-Attribute")
|
||||
description = _("There is an invalid path object in the document, the d-attribute is missing.")
|
||||
steps_to_solve = [
|
||||
_('* Run Extensions > Ink/Stitch > Troubleshoot > Cleanup Document...')
|
||||
]
|
||||
|
||||
|
||||
class EmptyDObject(EmbroideryElement):
|
||||
|
||||
def validation_warnings(self):
|
||||
yield EmptyD((0, 0))
|
||||
|
||||
def to_patches(self, last_patch):
|
||||
return []
|
||||
|
|
@ -1,9 +1,10 @@
|
|||
from ..commands import is_command
|
||||
from ..svg.tags import (EMBROIDERABLE_TAGS, SVG_IMAGE_TAG, SVG_POLYLINE_TAG,
|
||||
SVG_TEXT_TAG)
|
||||
from ..svg.tags import (EMBROIDERABLE_TAGS, SVG_IMAGE_TAG, SVG_PATH_TAG,
|
||||
SVG_POLYLINE_TAG, SVG_TEXT_TAG)
|
||||
from .auto_fill import AutoFill
|
||||
from .clone import Clone, is_clone
|
||||
from .element import EmbroideryElement
|
||||
from .empty_d_object import EmptyDObject
|
||||
from .fill import Fill
|
||||
from .image import ImageObject
|
||||
from .polyline import Polyline
|
||||
|
|
@ -19,6 +20,9 @@ def node_to_elements(node): # noqa: C901
|
|||
elif is_clone(node):
|
||||
return [Clone(node)]
|
||||
|
||||
elif node.tag == SVG_PATH_TAG and not node.get('d', ''):
|
||||
return [EmptyDObject(node)]
|
||||
|
||||
elif node.tag in EMBROIDERABLE_TAGS:
|
||||
element = EmbroideryElement(node)
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,8 @@ from ..elements.clone import is_clone, is_embroiderable_clone
|
|||
from ..i18n import _
|
||||
from ..svg import generate_unique_id
|
||||
from ..svg.tags import (CONNECTOR_TYPE, EMBROIDERABLE_TAGS, INKSCAPE_GROUPMODE,
|
||||
NOT_EMBROIDERABLE_TAGS, SVG_DEFS_TAG, SVG_GROUP_TAG)
|
||||
NOT_EMBROIDERABLE_TAGS, SVG_DEFS_TAG, SVG_GROUP_TAG,
|
||||
SVG_PATH_TAG)
|
||||
|
||||
SVG_METADATA_TAG = inkex.addNS("metadata", "svg")
|
||||
|
||||
|
|
@ -164,9 +165,9 @@ class InkstitchExtension(inkex.Effect):
|
|||
nodes.extend(self.descendants(child, selected, troubleshoot))
|
||||
|
||||
if selected:
|
||||
if node.tag in EMBROIDERABLE_TAGS or is_embroiderable_clone(node):
|
||||
if (node.tag in EMBROIDERABLE_TAGS or is_embroiderable_clone(node)) and not (node.tag == SVG_PATH_TAG and not node.get('d', '')):
|
||||
nodes.append(node)
|
||||
elif troubleshoot and (node.tag in NOT_EMBROIDERABLE_TAGS or is_clone(node)):
|
||||
elif troubleshoot and (node.tag in NOT_EMBROIDERABLE_TAGS or node.tag in EMBROIDERABLE_TAGS or is_clone(node)):
|
||||
nodes.append(node)
|
||||
|
||||
return nodes
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
import sys
|
||||
|
||||
from inkex import NSS
|
||||
|
||||
from ..elements import Fill, Stroke
|
||||
from ..i18n import _
|
||||
from .base import InkstitchExtension
|
||||
|
|
@ -22,13 +24,19 @@ class Cleanup(InkstitchExtension):
|
|||
# Remove selection, we want every element in the document
|
||||
self.selected = {}
|
||||
|
||||
count = 0
|
||||
svg = self.document.getroot()
|
||||
empty_d_objects = svg.xpath(".//svg:path[@d='' or not(@d)]", namespaces=NSS)
|
||||
for empty in empty_d_objects:
|
||||
empty.getparent().remove(empty)
|
||||
count += 1
|
||||
|
||||
if not self.get_elements():
|
||||
print >> sys.stderr, _("%s elements removed" % count)
|
||||
return
|
||||
|
||||
count = 0
|
||||
for element in self.elements:
|
||||
if (isinstance(element, Fill) and self.rm_fill and
|
||||
element.shape.area < self.fill_threshold):
|
||||
if (isinstance(element, Fill) and self.rm_fill and element.shape.area < self.fill_threshold):
|
||||
element.node.getparent().remove(element.node)
|
||||
count += 1
|
||||
if (isinstance(element, Stroke) and self.rm_stroke and
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue