Skip to content

Simple Inkscape Scripting v5.0.0

Latest
Compare
Choose a tag to compare
@spakin spakin released this 25 Dec 17:57
· 8 commits to master since this release
3f15215

This is a major new release of Simple Inkscape Scripting. It includes only one—very small—breaking change plus a lot of new features and other improvements.

Breaking change: ungroup applies the group's transform to each ungrouped object.
Reason: Retaining an object's appearance when it is ungrouped matches Inkscape's behavior and should be more intuitive.
Replacement: Pass preserve_transform=False as the final argument to ungroup to recover the pre-v5.0.0 behavior.

In addition to the above and the usual sorts of bug fixes, Simple Inkscape Scripting v5.0.0 provides a long list of new features:

  • Foreign XML can be included in an SVG file with the foreign function. This enables, for instance, the embedding of arbitrary HTML within an SVG document.
  • Document metadata (title, author, copyright, description, etc.) can be both read and written via the metadata variable.
  • A script can query its own filename with the script_filename variable.
  • Guides can be assigned labels. Labels of existing guides can be read and modified.
  • Inkscape actions can be invoked from a script using the apply_action function. Most operations the Inkscape GUI can perform are backed by an action, making apply_action a very powerful addition to Simple Inkscape Scripting. Run inkscape --action-list for a list of available actions.
  • A specialization of apply_action called apply_path_operation simplifies the invocation of path operations such as path union, path intersection, and path difference.
  • As a convenience, +, -, *, ^, /, and // can be applied to path objects to perform respectively path union, path difference, path intersection, path exclusion, path division, and path cut.
  • Simple Inkscape Scripting has been updated to work with Inkscape 1.3.
  • When saving an SVG document to a Simple Inkscape Scripting script, paths are written in terms of inkex PathCommands instead of strings. That is, instead of
path(['M', 8.7, 4.0, 'L', -2.2, 0.02, 'L', 8.7, -4.0, 'C', 7.0, -1.6, 7.0, 1.6, 8.7, 4.0, 'z'])

the generated script will contain

path([Move(8.7, 4.0), Line(-2.2, 0.02), Line(8.7, -4.0), Curve(7.0, -1.6, 7.0, 1.6, 8.7, 4.0), zoneClose()])
my_shape.scale(1.5, 'ul')
my_shape.rotate(14, 'c')

can be written more tersely as

my_shape.scale(1.5, 'ul').rotate(14, 'c')
  • Transformation methods accept nw, ne, se, and sw as synonyms for the anchor points ul, ur, lr, and ll, respectively. Additional anchor points n, e, s, and w are supported.
  • The to_path method now works on text objects.
  • A new z_sort function sorts a list of Simple Inkscape Scripting objects by increasing Z-order.
  • A shape's parent object (group or layer) can be retrieved with the get_parent method.

See the Simple Inkscape Scripting commit log for details of all of the above.