Inkscape.org
Creating New Extensions Starthelp on understanding how to convert extensions to v1.0
  1. #1
    Ellen Wasbø Ellen Wasbø @EllenWasbo

    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.

  2. #2
    Ellen Wasbø Ellen Wasbø @EllenWasbo

    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 :)

  3. #3
    Martin Owens Martin Owens @doctormo🌹🧀

    What did you end up writing?

  4. #4
    Ellen Wasbø Ellen Wasbø @EllenWasbo
    *

    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.

Inkscape Inkscape.org Inkscape Forum Creating New Extensions Starthelp on understanding how to convert extensions to v1.0