I have followed the instructions on getting my extension ready for v1.0, but now I struggle to understand how I should solve the deprecation warning for simplePath. I would appreciate some start help so that I hopefully get the hang of it and will be able to solve similar warnings on my own. This is my old code:
if node.tag == inkex.addNS('path','svg'): d = node.get('d') d = simplepath.formatPath( simplepath.parsePath(d) )
This is the warning (nested as I use two simplepath functions on the same line):
reopenSingleLineFont.py:41: DeprecationWarning: simplepath.parsePath -> element.path.to_arrays() d = simplepath.formatPath( simplepath.parsePath(d) ) reopenSingleLineFont.py:41: DeprecationWarning: simplepath.formatPath -> str(element.path) or str(Path(array)) d = simplepath.formatPath( simplepath.parsePath(d) )
I've tried several ways to write that last line of the code above, but all get new errors that I struggle to solve. What should the last line be here? I feel like fumbling around and struggle to find example code.
I found some better resources and I found the built in extensions as examples so now I have rewritten the whole code, not just that line. So I made it work :)
for id, node in self.selected.iteritems(): if node.tag == inkex.addNS('path','svg'): d = node.get('d') d = simplepath.formatPath( simplepath.parsePath(d) ) d = re.sub(r"Z","",d)
node.set('d',d)
New code:
for elem in self.svg.get_selected(): pp=elem.path.to_absolute() #remove transformation matrix elem.path = re.sub(r"Z","",str(pp))
The previous code actually had another option removing the last line segment of each path. Different solutions worked on different Inkscape versions and mac vs windows. Now the new code work with v1.0 and Windows 10, at least.
I have followed the instructions on getting my extension ready for v1.0, but now I struggle to understand how I should solve the deprecation warning for simplePath. I would appreciate some start help so that I hopefully get the hang of it and will be able to solve similar warnings on my own. This is my old code:
if node.tag == inkex.addNS('path','svg'):
d = node.get('d')
d = simplepath.formatPath( simplepath.parsePath(d) )
This is the warning (nested as I use two simplepath functions on the same line):
reopenSingleLineFont.py:41: DeprecationWarning: simplepath.parsePath -> element.path.to_arrays()
d = simplepath.formatPath( simplepath.parsePath(d) )
reopenSingleLineFont.py:41: DeprecationWarning: simplepath.formatPath -> str(element.path) or str(Path(array))
d = simplepath.formatPath( simplepath.parsePath(d) )
I've tried several ways to write that last line of the code above, but all get new errors that I struggle to solve. What should the last line be here? I feel like fumbling around and struggle to find example code.
I found some better resources and I found the built in extensions as examples so now I have rewritten the whole code, not just that line. So I made it work :)
What did you end up writing?
Previous code:
for id, node in self.selected.iteritems():
if node.tag == inkex.addNS('path','svg'):
d = node.get('d')
d = simplepath.formatPath( simplepath.parsePath(d) )
d = re.sub(r"Z","",d)
node.set('d',d)
New code:
for elem in self.svg.get_selected():
pp=elem.path.to_absolute() #remove transformation matrix
elem.path = re.sub(r"Z","",str(pp))
The previous code actually had another option removing the last line segment of each path. Different solutions worked on different Inkscape versions and mac vs windows. Now the new code work with v1.0 and Windows 10, at least.