cleaned some code

This commit is contained in:
leyghisbb 2021-04-18 18:21:23 +02:00
parent 41663ffd86
commit 313b0c3b63
13 changed files with 368 additions and 367 deletions

View File

@ -454,7 +454,7 @@ class FoldedCardLayoutGuidesEffect(inkex.EffectExtension):
### GUIDES ### GUIDES
# remove all the existing guides # remove all the existing guides
[node.getparent().remove(node) for node in self.document.xpath('//sodipodi:guide',namespaces=inkex.NSS)] [node.delete() for node in self.document.xpath('//sodipodi:guide',namespaces=inkex.NSS)]
# create the generator object # create the generator object
gen = LineGeneratorBase.CreateLineGenerator(opt.layout, opt.orientation, opt.card_width, opt.card_height, opt.card_margin, opt.bleed_margin, pageWidth, pageHeight, opt.page_margin, self.svg.unittouu) gen = LineGeneratorBase.CreateLineGenerator(opt.layout, opt.orientation, opt.card_width, opt.card_height, opt.card_margin, opt.bleed_margin, pageWidth, pageHeight, opt.page_margin, self.svg.unittouu)
@ -463,7 +463,7 @@ class FoldedCardLayoutGuidesEffect(inkex.EffectExtension):
### FOLD LINES ### FOLD LINES
# remove any existing 'Crop marks' layer # remove any existing 'Crop marks' layer
[node.getparent().remove(node) for node in self.document.xpath("//svg:g[@inkscape:label='Crop Marks']",namespaces=inkex.NSS)] [node.delete() for node in self.document.xpath("//svg:g[@inkscape:label='Crop Marks']",namespaces=inkex.NSS)]
svg = self.document.xpath('//svg:svg', namespaces=inkex.NSS)[0] svg = self.document.xpath('//svg:svg', namespaces=inkex.NSS)[0]
layer = etree.SubElement(svg, inkex.addNS('g',"svg"), {}) layer = etree.SubElement(svg, inkex.addNS('g',"svg"), {})

View File

@ -435,7 +435,7 @@ class HexLayoutGuidesEffect(inkex.Effect):
### GUIDES ### GUIDES
# remove all the existing guides # remove all the existing guides
[node.getparent().remove(node) for node in self.document.xpath('//sodipodi:guide',namespaces=inkex.NSS)] [node.delete() for node in self.document.xpath('//sodipodi:guide',namespaces=inkex.NSS)]
# create the object generator # create the object generator
gen = HexGeneratorBase.CreateHexGenerator(opt.HexDiameter, opt.HexMargin, opt.BleedMargin, pageWidth, pageHeight, opt.PageMargin, self.svg.unittouu) gen = HexGeneratorBase.CreateHexGenerator(opt.HexDiameter, opt.HexMargin, opt.BleedMargin, pageWidth, pageHeight, opt.PageMargin, self.svg.unittouu)
@ -444,7 +444,7 @@ class HexLayoutGuidesEffect(inkex.Effect):
### CROP MARKS ### CROP MARKS
# remove any existing 'Crop marks' layer # remove any existing 'Crop marks' layer
[node.getparent().remove(node) for node in self.document.xpath("//svg:g[@inkscape:label='Crop Marks']",namespaces=inkex.NSS)] [node.delete() for node in self.document.xpath("//svg:g[@inkscape:label='Crop Marks']",namespaces=inkex.NSS)]
svg = self.document.xpath('//svg:svg', namespaces=inkex.NSS)[0] svg = self.document.xpath('//svg:svg', namespaces=inkex.NSS)[0]
layer = etree.SubElement(svg, inkex.addNS('g',"svg"), {}) layer = etree.SubElement(svg, inkex.addNS('g',"svg"), {})

View File

@ -124,7 +124,7 @@ class RemoveDuplicateGuidesEffect(inkex.EffectExtension):
# now remove all the excess guides # now remove all the excess guides
for serial in groups: for serial in groups:
for guide in groups[serial][1:]: # keep the first member of group for guide in groups[serial][1:]: # keep the first member of group
guide.node.getparent().remove(guide.node) guide.node.delete()
if __name__ == '__main__': if __name__ == '__main__':
effect = RemoveDuplicateGuidesEffect().run() effect = RemoveDuplicateGuidesEffect().run()

View File

@ -27,21 +27,21 @@ class ApplyTransform(inkex.EffectExtension):
self.recursiveFuseTransform(self.document.getroot()) self.recursiveFuseTransform(self.document.getroot())
@staticmethod @staticmethod
def objectToPath(node): def objectToPath(element):
if node.tag == inkex.addNS('g', 'svg'): if element.tag == inkex.addNS('g', 'svg'):
return node return element
if node.tag == inkex.addNS('path', 'svg') or node.tag == 'path': if element.tag == inkex.addNS('path', 'svg') or element.tag == 'path':
for attName in node.attrib.keys(): for attName in element.attrib.keys():
if ("sodipodi" in attName) or ("inkscape" in attName): if ("sodipodi" in attName) or ("inkscape" in attName):
del node.attrib[attName] del element.attrib[attName]
return node return element
return node return element
def scaleStrokeWidth(self, node, transf): def scaleStrokeWidth(self, element, transf):
if 'style' in node.attrib: if 'style' in element.attrib:
style = node.attrib.get('style') style = element.attrib.get('style')
style = dict(Style.parse_str(style)) style = dict(Style.parse_str(style))
update = False update = False
@ -55,32 +55,32 @@ class ApplyTransform(inkex.EffectExtension):
pass pass
if update: if update:
node.attrib['style'] = Style(style).to_str() element.attrib['style'] = Style(style).to_str()
def recursiveFuseTransform(self, node, transf=[[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]): def recursiveFuseTransform(self, element, transf=[[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]):
transf = Transform(transf) * Transform(node.get("transform", None)) #a, b, c, d = linear transformations / e, f = translations transf = Transform(transf) * Transform(element.get("transform", None)) #a, b, c, d = linear transformations / e, f = translations
if 'transform' in node.attrib: if 'transform' in element.attrib:
del node.attrib['transform'] del element.attrib['transform']
node = ApplyTransform.objectToPath(node) element = ApplyTransform.objectToPath(element)
if transf == NULL_TRANSFORM: if transf == NULL_TRANSFORM:
# Don't do anything if there is effectively no transform applied # Don't do anything if there is effectively no transform applied
# reduces alerts for unsupported nodes # reduces alerts for unsupported elements
pass pass
elif 'd' in node.attrib: elif 'd' in element.attrib:
d = node.get('d') d = element.get('d')
p = CubicSuperPath(d) p = CubicSuperPath(d)
p = Path(p).to_absolute().transform(transf, True) p = Path(p).to_absolute().transform(transf, True)
node.set('d', str(Path(CubicSuperPath(p).to_path()))) element.set('d', str(Path(CubicSuperPath(p).to_path())))
self.scaleStrokeWidth(node, transf) self.scaleStrokeWidth(element, transf)
elif node.tag in [inkex.addNS('polygon', 'svg'), elif element.tag in [inkex.addNS('polygon', 'svg'),
inkex.addNS('polyline', 'svg')]: inkex.addNS('polyline', 'svg')]:
points = node.get('points') points = element.get('points')
points = points.strip().split(' ') points = points.strip().split(' ')
for k, p in enumerate(points): for k, p in enumerate(points):
if ',' in p: if ',' in p:
@ -91,24 +91,24 @@ class ApplyTransform(inkex.EffectExtension):
p = ','.join(p) p = ','.join(p)
points[k] = p points[k] = p
points = ' '.join(points) points = ' '.join(points)
node.set('points', points) element.set('points', points)
self.scaleStrokeWidth(node, transf) self.scaleStrokeWidth(element, transf)
elif node.tag in [inkex.addNS("ellipse", "svg"), inkex.addNS("circle", "svg")]: elif element.tag in [inkex.addNS("ellipse", "svg"), inkex.addNS("circle", "svg")]:
def isequal(a, b): def isequal(a, b):
return abs(a - b) <= transf.absolute_tolerance return abs(a - b) <= transf.absolute_tolerance
if node.TAG == "ellipse": if element.TAG == "ellipse":
rx = float(node.get("rx")) rx = float(element.get("rx"))
ry = float(node.get("ry")) ry = float(element.get("ry"))
else: else:
rx = float(node.get("r")) rx = float(element.get("r"))
ry = rx ry = rx
cx = float(node.get("cx")) cx = float(element.get("cx"))
cy = float(node.get("cy")) cy = float(element.get("cy"))
sqxy1 = (cx - rx, cy - ry) sqxy1 = (cx - rx, cy - ry)
sqxy2 = (cx + rx, cy - ry) sqxy2 = (cx + rx, cy - ry)
sqxy3 = (cx + rx, cy + ry) sqxy3 = (cx + rx, cy + ry)
@ -116,8 +116,8 @@ class ApplyTransform(inkex.EffectExtension):
newxy2 = transf.apply_to_point(sqxy2) newxy2 = transf.apply_to_point(sqxy2)
newxy3 = transf.apply_to_point(sqxy3) newxy3 = transf.apply_to_point(sqxy3)
node.set("cx", (newxy1[0] + newxy3[0]) / 2) element.set("cx", (newxy1[0] + newxy3[0]) / 2)
node.set("cy", (newxy1[1] + newxy3[1]) / 2) element.set("cy", (newxy1[1] + newxy3[1]) / 2)
edgex = math.sqrt( edgex = math.sqrt(
abs(newxy1[0] - newxy2[0]) ** 2 + abs(newxy1[1] - newxy2[1]) ** 2 abs(newxy1[0] - newxy2[0]) ** 2 + abs(newxy1[1] - newxy2[1]) ** 2
) )
@ -126,31 +126,32 @@ class ApplyTransform(inkex.EffectExtension):
) )
if not isequal(edgex, edgey) and ( if not isequal(edgex, edgey) and (
node.TAG == "circle" element.TAG == "circle"
or not isequal(newxy2[0], newxy3[0]) or not isequal(newxy2[0], newxy3[0])
or not isequal(newxy1[1], newxy2[1]) or not isequal(newxy1[1], newxy2[1])
): ):
inkex.utils.errormsg( inkex.utils.errormsg(
"Warning: Shape %s (%s) is approximate only, try Object to path first for better results" "Warning: Shape %s (%s) is approximate only, try Object to path first for better results"
% (node.TAG, node.get("id")) % (element.TAG, element.get("id"))
) )
if node.TAG == "ellipse": if element.TAG == "ellipse":
node.set("rx", edgex / 2) element.set("rx", edgex / 2)
node.set("ry", edgey / 2) element.set("ry", edgey / 2)
else: else:
node.set("r", edgex / 2) element.set("r", edgex / 2)
elif node.tag == inkex.addNS("use", "svg"): # this is unstable at the moment
elif element.tag == inkex.addNS("use", "svg"):
href = None href = None
old_href_key = '{http://www.w3.org/1999/xlink}href' old_href_key = '{http://www.w3.org/1999/xlink}href'
new_href_key = 'href' new_href_key = 'href'
if node.attrib.has_key(old_href_key) is True: # {http://www.w3.org/1999/xlink}href (which gets displayed as 'xlink:href') attribute is deprecated. the newer attribute is just 'href' if element.attrib.has_key(old_href_key) is True: # {http://www.w3.org/1999/xlink}href (which gets displayed as 'xlink:href') attribute is deprecated. the newer attribute is just 'href'
href = node.attrib.get(old_href_key) href = element.attrib.get(old_href_key)
#node.attrib.pop(old_href_key) #element.attrib.pop(old_href_key)
if node.attrib.has_key(new_href_key) is True: if element.attrib.has_key(new_href_key) is True:
href = node.attrib.get(new_href_key) #we might overwrite the previous deprecated xlink:href but it's okay href = element.attrib.get(new_href_key) #we might overwrite the previous deprecated xlink:href but it's okay
#node.attrib.pop(new_href_key) #element.attrib.pop(new_href_key)
#get the linked object from href attribute #get the linked object from href attribute
linkedObject = self.document.getroot().xpath("//*[@id = '%s']" % href.lstrip('#')) #we must remove hashtag symbol linkedObject = self.document.getroot().xpath("//*[@id = '%s']" % href.lstrip('#')) #we must remove hashtag symbol
@ -161,14 +162,14 @@ class ApplyTransform(inkex.EffectExtension):
mask = None #image might have an alpha channel mask = None #image might have an alpha channel
new_mask_id = self.svg.get_unique_id("mask") new_mask_id = self.svg.get_unique_id("mask")
newMask = None newMask = None
if node.attrib.has_key('mask') is True: if element.attrib.has_key('mask') is True:
mask = node.attrib.get('mask') mask = element.attrib.get('mask')
#node.attrib.pop('mask') #element.attrib.pop('mask')
#get the linked mask from mask attribute. We remove the old and create a new #get the linked mask from mask attribute. We remove the old and create a new
if mask is not None: if mask is not None:
linkedMask = self.document.getroot().xpath("//*[@id = '%s']" % mask.lstrip('url(#').rstrip(')')) #we must remove hashtag symbol linkedMask = self.document.getroot().xpath("//*[@id = '%s']" % mask.lstrip('url(#').rstrip(')')) #we must remove hashtag symbol
linkedMask[0].getparent().remove(linkedMask[0]) linkedMask[0].delete()
maskAttributes = {'id': new_mask_id} maskAttributes = {'id': new_mask_id}
newMask = etree.SubElement(self.document.getroot(), inkex.addNS('mask', 'svg'), maskAttributes) newMask = etree.SubElement(self.document.getroot(), inkex.addNS('mask', 'svg'), maskAttributes)
@ -182,25 +183,25 @@ class ApplyTransform(inkex.EffectExtension):
linkedObjectCopy.set('mask', 'url(#' + new_mask_id + ')') linkedObjectCopy.set('mask', 'url(#' + new_mask_id + ')')
maskRectAttributes = {'x': '{:1.6f}'.format(transf.e), 'y': '{:1.6f}'.format(transf.f), 'width': '{:1.6f}'.format(width), 'height': '{:1.6f}'.format(height), 'style':'fill:#ffffff;'} maskRectAttributes = {'x': '{:1.6f}'.format(transf.e), 'y': '{:1.6f}'.format(transf.f), 'width': '{:1.6f}'.format(width), 'height': '{:1.6f}'.format(height), 'style':'fill:#ffffff;'}
maskRect = etree.SubElement(newMask, inkex.addNS('rect', 'svg'), maskRectAttributes) maskRect = etree.SubElement(newMask, inkex.addNS('rect', 'svg'), maskRectAttributes)
else:
self.recursiveFuseTransform(linkedObjectCopy, transf)
self.document.getroot().append(linkedObjectCopy) #for each svg:use we append a copy to the document root self.document.getroot().append(linkedObjectCopy) #for each svg:use we append a copy to the document root
node.getparent().remove(node) #then we remove the use object element.delete() #then we remove the use object
else:
#self.recursiveFuseTransform(linkedObjectCopy, transf)
self.recursiveFuseTransform(element.unlink(), transf)
elif node.tag in [inkex.addNS('rect', 'svg'), elif element.tag in [inkex.addNS('rect', 'svg'),
inkex.addNS('text', 'svg'), inkex.addNS('text', 'svg'),
inkex.addNS('image', 'svg')]: inkex.addNS('image', 'svg')]:
inkex.utils.errormsg( inkex.utils.errormsg(
"Shape %s (%s) not yet supported, try Object to path first" "Shape %s (%s) not yet supported, try Object to path first"
% (node.TAG, node.get("id")) % (element.TAG, element.get("id"))
) )
else: else:
# e.g. <g style="..."> # e.g. <g style="...">
self.scaleStrokeWidth(node, transf) self.scaleStrokeWidth(element, transf)
for child in node.getchildren(): for child in element.getchildren():
self.recursiveFuseTransform(child, transf) self.recursiveFuseTransform(child, transf)
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -260,7 +260,7 @@ class ChainPaths(inkex.EffectExtension):
if not len(new): if not len(new):
# node.clear() # node.clear()
if node.getparent() is not None: if node.getparent() is not None:
node.getparent().remove(node) node.delete()
obsoleted += 1 obsoleted += 1
if debug: inkex.utils.debug("Path node obsoleted: " +str(id)) if debug: inkex.utils.debug("Path node obsoleted: " +str(id))
else: else:

View File

@ -111,7 +111,7 @@ class ContourScanner(inkex.EffectExtension):
parent.insert(idx, replacedNode) parent.insert(idx, replacedNode)
idSuffix += 1 idSuffix += 1
self.replacedNodes.append(replacedNode) self.replacedNodes.append(replacedNode)
parent.remove(node) node.delete()
for child in node: for child in node:
self.breakContours(child) self.breakContours(child)
@ -158,7 +158,7 @@ class ContourScanner(inkex.EffectExtension):
node.attrib['style'] = Style(style).to_str() node.attrib['style'] = Style(style).to_str()
if self.options.remove_opened: if self.options.remove_opened:
try: try:
node.getparent().remove(node) node.delete()
except AttributeError: except AttributeError:
pass #we ignore that parent can be None pass #we ignore that parent can be None
if closed == True: if closed == True:
@ -169,7 +169,7 @@ class ContourScanner(inkex.EffectExtension):
node.attrib['style'] = Style(style).to_str() node.attrib['style'] = Style(style).to_str()
if self.options.remove_closed: if self.options.remove_closed:
try: try:
node.getparent().remove(node) node.delete()
except AttributeError: except AttributeError:
pass #we ignore that parent can be None pass #we ignore that parent can be None
@ -220,7 +220,7 @@ class ContourScanner(inkex.EffectExtension):
node.attrib['style'] = intersectionStyle node.attrib['style'] = intersectionStyle
if self.options.remove_selfintersecting: if self.options.remove_selfintersecting:
if node.getparent() is not None: #might be already been deleted by previously checked settings so check again if node.getparent() is not None: #might be already been deleted by previously checked settings so check again
node.getparent().remove(node) node.delete()
#draw intersections segment lines - useless at the moment. We could use this information to cut the original polyline to get a new curve path which included the intersection points #draw intersections segment lines - useless at the moment. We could use this information to cut the original polyline to get a new curve path which included the intersection points
#isectSegs = poly_point_isect.isect_polygon_include_segments(points) #isectSegs = poly_point_isect.isect_polygon_include_segments(points)
@ -254,7 +254,7 @@ class ContourScanner(inkex.EffectExtension):
if len(intersectionGroup.getchildren()) == 0: if len(intersectionGroup.getchildren()) == 0:
intersectionGroupParent = intersectionGroup.getparent() intersectionGroupParent = intersectionGroup.getparent()
if intersectionGroupParent is not None: if intersectionGroupParent is not None:
intersectionGroup.getparent().remove(intersectionGroup) intersectionGroup.delete()
#put the node into the intersectionGroup to bundle the path with it's error markers. If removal is selected we need to avoid intersectionGroup.insert(), because it will break the removal #put the node into the intersectionGroup to bundle the path with it's error markers. If removal is selected we need to avoid intersectionGroup.insert(), because it will break the removal
elif self.options.remove_selfintersecting == False: elif self.options.remove_selfintersecting == False:
intersectionGroup.insert(0, node) intersectionGroup.insert(0, node)

View File

@ -287,7 +287,7 @@ class FilletChamfer(inkex.EffectExtension):
self.addEle(inkex.addNS('path','svg'), node.getparent(), attrib) self.addEle(inkex.addNS('path','svg'), node.getparent(), attrib)
if self.options.remove: if self.options.remove:
node.getparent().remove(node) node.delete()
if __name__ == '__main__': if __name__ == '__main__':
FilletChamfer().run() FilletChamfer().run()

View File

@ -164,7 +164,7 @@ class Imagetracerjs (inkex.EffectExtension):
#remove the old image or not #remove the old image or not
if self.options.keeporiginal is not True: if self.options.keeporiginal is not True:
node.getparent().remove(node) node.delete()
else: else:
inkex.utils.debug("No image found for tracing. Please select an image first.") inkex.utils.debug("No image found for tracing. Please select an image first.")

View File

@ -311,7 +311,7 @@ class LineShading(inkex.Effect):
self.draw_path(node, png_temp_file) self.draw_path(node, png_temp_file)
shutil.rmtree(tmp_dir) shutil.rmtree(tmp_dir)
if self.options.remove: if self.options.remove:
node.getparent().remove(node) node.delete()
return return
if not image_selected_flag: if not image_selected_flag:
inkex.errormsg("Please select an image") inkex.errormsg("Please select an image")

View File

@ -287,7 +287,7 @@ class PathOps(inkex.EffectExtension):
if not self.options.keep_top: if not self.options.keep_top:
top_node = self.svg.getElementById(top_path) top_node = self.svg.getElementById(top_path)
if top_node is not None: if top_node is not None:
top_node.getparent().remove(top_node) top_node.delete()
# purge missing tagrefs (see below) # purge missing tagrefs (see below)
self.update_tagrefs() self.update_tagrefs()
# clean up # clean up
@ -353,7 +353,7 @@ class PathOps(inkex.EffectExtension):
href = tagref.get(inkex.addNS('href', 'xlink'))[1:] href = tagref.get(inkex.addNS('href', 'xlink'))[1:]
if self.svg.getElementById(href) is None: if self.svg.getElementById(href) is None:
if mode == 'purge': if mode == 'purge':
tagref.getparent().remove(tagref) tagref.delete()
elif mode == 'placeholder': elif mode == 'placeholder':
temp = etree.Element(inkex.addNS('path', 'svg')) temp = etree.Element(inkex.addNS('path', 'svg'))
temp.set('id', href) temp.set('id', href)

View File

@ -151,7 +151,7 @@ class Primitive (inkex.EffectExtension):
exit(1) exit(1)
#remove the old image or not #remove the old image or not
if self.options.keeporiginal is not True: if self.options.keeporiginal is not True:
node.getparent().remove(node) node.delete()
# create clip path to remove the stuffy surroundings # create clip path to remove the stuffy surroundings
if self.options.cliprect: if self.options.cliprect:

View File

@ -260,7 +260,7 @@ class Shapes(inkex.Effect):
if midtype=="pillowrombus": if midtype=="pillowrombus":
self.pillows(midtype, a, node, l, t, r, b, cX, cY) self.pillows(midtype, a, node, l, t, r, b, cX, cY)
pnts = [] pnts = []
if deleteorigin: node.getparent().remove(node) if deleteorigin: node.delete()
if (sub_bb=='chamfer'): if (sub_bb=='chamfer'):
if chtype=="chamfer": if chtype=="chamfer":
@ -300,7 +300,7 @@ class Shapes(inkex.Effect):
self.pillows(chtype, a, node, l, t, r, b, cX, cY) self.pillows(chtype, a, node, l, t, r, b, cX, cY)
pnts = [] pnts = []
dS = "M %sZ" dS = "M %sZ"
if deleteorigin: node.getparent().remove(node) if deleteorigin: node.delete()
if chtype == "spiralrect": if chtype == "spiralrect":
An, Al = (an, al) An, Al = (an, al)
pnts = [[l,t], [An,0], [0,Al], [-An,0], [0,-Al+a]] pnts = [[l,t], [An,0], [0,Al], [-An,0], [0,-Al+a]]
@ -380,7 +380,7 @@ class Shapes(inkex.Effect):
nn = svgCircle(node.getparent(), rad, px, py) nn = svgCircle(node.getparent(), rad, px, py)
self.estilo(nn,node) self.estilo(nn,node)
pnts=[] pnts=[]
if deleteorigin: node.getparent().remove(node) if deleteorigin: node.delete()
if sh=='nodes': if sh=='nodes':
# get verts # get verts
obj, posh, posv, objS, oY =(sO.obj, int(sO.posh), int(sO.posv), sO.objsize, sO.ordery) obj, posh, posv, objS, oY =(sO.obj, int(sO.posh), int(sO.posv), sO.objsize, sO.ordery)
@ -450,7 +450,7 @@ class Shapes(inkex.Effect):
orderY.sort(key=myFunc) orderY.sort(key=myFunc)
for item in orderY: for item in orderY:
grp.append( item[1]) grp.append( item[1])
if deleteorigin: node.getparent().remove(node) if deleteorigin: node.delete()
# ##############################3 # ##############################3
d = "" d = ""
@ -460,7 +460,7 @@ class Shapes(inkex.Effect):
d += "%s%s,%s " % (ss, str(n[0]),str(n[1])) d += "%s%s,%s " % (ss, str(n[0]),str(n[1]))
nn = self.addEle('path',pp, {'d':dS % (d)}) nn = self.addEle('path',pp, {'d':dS % (d)})
self.estilo(nn,node) self.estilo(nn,node)
if deleteorigin: node.getparent().remove(node) if deleteorigin: node.delete()
def makeRel(self,arr): def makeRel(self,arr):
b = arr[:] b = arr[:]
@ -608,7 +608,7 @@ class Shapes(inkex.Effect):
# curva1 # curva1
nn = self.addEle('path',pp,{'d':"M %sZ" % (sCurva1),'style':'stroke-width:0.02;fill:#cc0000;stroke:#000000;'}) nn = self.addEle('path',pp,{'d':"M %sZ" % (sCurva1),'style':'stroke-width:0.02;fill:#cc0000;stroke:#000000;'})
self.estilo(nn,node) self.estilo(nn,node)
if deleteorigin: node.getparent().remove(node) if deleteorigin: node.delete()
def drawArrow(self, sO, an, al, l, t): def drawArrow(self, sO, an, al, l, t):
arrowType = sO.arrowtype arrowType = sO.arrowtype

View File

@ -384,7 +384,7 @@ class vpypetools (inkex.EffectExtension):
trajectoriesLayer[0].attrib.pop('fill') # remove unneccesary fill attribute trajectoriesLayer[0].attrib.pop('fill') # remove unneccesary fill attribute
else: else:
if len(trajectoriesLayer) > 0: if len(trajectoriesLayer) > 0:
trajectoriesLayer[0].getparent().remove(trajectoriesLayer[0]) trajectoriesLayer[0].delete()
lineLayers = import_doc.getroot().xpath("//svg:g[not(@id='pen_up_trajectories')]", namespaces=inkex.NSS) #all layer except the pen_up trajectories layer lineLayers = import_doc.getroot().xpath("//svg:g[not(@id='pen_up_trajectories')]", namespaces=inkex.NSS) #all layer except the pen_up trajectories layer
if self.options.use_style_of_first_element is True and self.options.input_handling == "paths" and firstElementStyle is not None: if self.options.use_style_of_first_element is True and self.options.input_handling == "paths" and firstElementStyle is not None:
@ -420,7 +420,7 @@ class vpypetools (inkex.EffectExtension):
# Remove selection objects to do a real replace with new objects from vpype document # Remove selection objects to do a real replace with new objects from vpype document
if self.options.keep_objects is False: if self.options.keep_objects is False:
for node in nodesToWork: for node in nodesToWork:
node.getparent().remove(node) node.delete()
if __name__ == '__main__': if __name__ == '__main__':
vpypetools().run() vpypetools().run()