Inkscape.org
Creating New Extensions command.args return a float
  1. #1
    FrankI4466 FrankI4466 @FrankI4466
    *

    Hi,

    I'm using this function in this code : 

     

        def get_first_point(self, d):

            path = Path(d)

            for command in path:

                if isinstance(command, Move):

                    first_point = command.args[0]

                    return first_point

    then this return a float, i expected a tuple of float.(https://inkscape.gitlab.io/extensions/documentation/source/inkex.paths.html#inkex.paths.Path.PathCommandProxy.args)

    Is it a bug ?

    For example on this path "M 89.2551 77.2901 C 89.2551 77.2901 120.079 77.2901 120.079 77.2901" it return  89.2551 I expected (89.2551, 77.2901)

  2. #2
    inklinea inklinea @inklinea⛰️

    I think it might be a documentation error or something in 1.4 ? I'm not sure.

    However you can get this in from:

    selection_list = self.svg.selected
    if len(selection_list) < 1:
    return

    for path_element in selection_list.filter(inkex.PathElement):

    path = path_element.path

    for entry in path:
    letter = entry.letter
    entry_args = entry.args
    inkex.errormsg(f'letter: {letter} args: {entry_args}')

  3. #3
    inklinea inklinea @inklinea⛰️
    *

    Further clarifed, the path proxy is accessed via:

    path = path_element.path

    path_proxy = path.proxy_iterator()

    for item in path_proxy:
    inkex.errormsg(item.args)

  4. #4
    FrankI4466 FrankI4466 @FrankI4466

    Thank's. I have split the path and put data in a tuple.