Mimsy Were the Borogoves

Hacks: Articles about programming in Python, Perl, Swift, BASIC, and whatever else I happen to feel like hacking at.

Get element by id in Inkscape

Jerry Stratton, April 24, 2010

If you’re automating the change of an Inkscape image, you often will know the Id of the element(s) you want to change.

Normally in XML, you would get the root node and use getElementById on that node. Apparently that’s not how Python does things, so Inkscape adds a getElementById method to the inkex.Effect class.

[toggle code]

  • class DuplicateMultiple(inkex.Effect):
    • def effect(self):
      • #get the logo
      • logo = self.getElementById('hoboLogo')
      • #do stuff to the logo

You can use “set” to set the style, transform, or other attributes of the Inkscape object, or anything else you would normally do to a selected node in your Inkscape effect.

  1. <- SQLite duplicate strings
  2. Maven: SQLite front end ->