Inkscape.org
Creating New Extensions Replacements for cubicsuperpath functions deprecated in 1.x
  1. #1
    DrWiggly DrWiggly @DrWiggly

    I have modified the Guilloche Contour extension so that it runs in version 1.1 and gives the same results as the older version running in version 0.92. I was unable, however, to find replacements for some of the functions in cubicsuperpath that have been deprecated in 1.x. Fortunately, though the functions are deprecated, they still perform correctly.

    Can anyone help me with finding replacement functions for the following?

    guilloche_contour.py:176: DeprecationWarning: cubicsuperpath.parsePath -> None
      return cubicsuperpath.parsePath(d)
    guilloche_contour.py:649: DeprecationWarning: cubicsuperpath.parsePath -> None
      patternCubicPath = cubicsuperpath.parsePath(pattern.get('d'))
    guilloche_contour.py:716: DeprecationWarning: cubicsuperpath.formatPath -> None
      pattern.set('d', cubicsuperpath.formatPath(resPath))
    C:\Program Files\Inkscape1.1\share\inkscape\extensions\inkex\deprecated-simple\cubicsuperpath.py:41: DeprecationWarning: cubicsuperpath.unCubicSuperPath -> None
      return str(paths.Path(unCubicSuperPath(p)))

     

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

    I struggle to get around with the limited documentation myself and as you understand I'm no expert, but this have worked for me as a skeleton of code when working on selected paths:

    if not self.svg.selected:
       raise inkex.AbortExtension("Please select an object.")
            
       for id, elem in self.svg.selection.id_dict().items():

         pp=elem.path.to_absolute() # to_absolute might be unnecessary, but I often would like to get rid of transformation matrix and more

         for sub in pp.to_superpath():

                     ....

              elem.path = CubicSuperPath(new).to_path(curves_only=True) # as formatPath used to convert back - 'new' is the variable with the modified superpath

  3. #3
    DrWiggly DrWiggly @DrWiggly

    EllenWasbo,

    Thanks for your reply. It was useful to see your outline of how to do an extension.

    Unfortunately, the Guilloche Contour extension didn't follow that pattern exactly, nonetheless it put me in the right frame of mind.

    My new version, in limited tests, functions like the 0.9x version, and it's free of all deprecation messages.

    I'll offer the following way of dealing with deprecation messages that has worked for me.

    1)  Go to the old 0.9x code and study what the old code did.

    2)  Go to the new code and find the deprecation code, especially the suggested replacement.

    3)  Replace the old line of code with the suggested replacement, chaining together replacements to fit  nested functions, and being sure to substitute your variables for the example variables.

    4) If needed, print out the result with the old version and the new and reconcile differences.

     

Inkscape Inkscape.org Inkscape Forum Creating New Extensions Replacements for cubicsuperpath functions deprecated in 1.x