Inkscape.org
Creating New Extensions Path operations like difference, intersection, exclusion
  1. #1
    aleereza aleereza @aleereza

    Hi,

    I couldn't find any function in inkex package to do path operations like difference (Ctrl + -), intersection (Ctrl + *) or exclusion (Ctrl + ^). anyone can help?

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

    These operations cannot be found in the inkex package, but you could take a look at the inx-pathops extension. In that extension command line operations inkex.command is used to perform the boolean operations.

  3. #3
    aleereza aleereza @aleereza

    Thank you Ellen. I found below function in pathops source which creates a list of actions and then runs it by calling inkscape(svgfile, "--with-gui", actions=actions)

    are you aware of any documentation where I can find more about this inkscape api. I couldn't find much in https://inkscape.gitlab.io/extensions/documentation/inkex.command.html

        from inkex.command import inkscape
    
        def run_pathops(self, svgfile, top_path, id_list, ink_verb, dry_run=False):
            """Run path ops with top_path on a list of other object ids."""
            # build list with command line arguments
            actions_list = []
            for node_id in id_list:
                actions_list.append("select-by-id:" + top_path)
                actions_list.append("EditDuplicate")
                actions_list.append("select-by-id:" + node_id)
                actions_list.append(ink_verb)
                actions_list.append("EditDeselect")
            actions_list.append("FileSave")
            actions_list.append("FileQuit")
            actions = ";".join(actions_list)
            # process command list
            if dry_run:
                inkex.utils.debug(" ".join(["inkscape", "--with-gui", "--actions=" + "\"" + actions + 
                "\"", svgfile]))
            else:
                inkscape(svgfile, "--with-gui", actions=actions)

     

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

    I have "learning to run inkscape from command lines" on my todo list, but know near to nothing per se. Maybe this command line builder from inklinea could help you: https://inkscape.org/forums/other/inkscape-command-line-builder-work-in-progress/#c23571.

    Or read more about command line here: https://wiki.inkscape.org/wiki/index.php/Using_the_Command_Line

  5. #5
    aleereza aleereza @aleereza

    Thanks a lot.

Inkscape Inkscape.org Inkscape Forum Creating New Extensions Path operations like difference, intersection, exclusion