Calling Inkscape Functions from Python

General discussions about Inkscape.
Cerin
Posts: 3
Joined: Sun Mar 23, 2008 9:44 am

Calling Inkscape Functions from Python

Postby Cerin » Mon Aug 23, 2010 11:24 pm

How would I call Inkscape functions from Python without loading the full Inkscape GUI? I'm aware Inkscape's Python extension feature, but I believe this assumes you've got Inkscape open and are running Python inside of it. I want to write a small Python script, that can create a simple path and perform Inkscape's Inset() or Simplify() path effects on it. Is that currently possible?

Regards,
Chris

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: Calling Inkscape Functions from Python

Postby ~suv » Tue Aug 24, 2010 3:52 am

Cerin wrote:I want to write a small Python script, that can create a simple path and perform Inkscape's Inset() or Simplify() path effects on it. Is that currently possible?

By using verbs many of Inkscape's commands can be called from the command line (it still opens the GUI window, but does not require user interaction). Creating a path or shape however is not possible from the command line in current stable releases.

Example from the Inkscape man page:

Code: Select all

inkscape filename.svg --select=path1555 --verb=EditDuplicate --verb=ObjectRotate90 --verb=FileSave --verb=FileClose


The development branch has the new dbus scripting API merged (a GSoC project from 2009), but most likely it only works on linux at the moment. Unfortunately the documentation is not available online - I can only refer to discussions from 2009 on the inkscape-devel mailing list:
Subject: GSoC Idea: Inkscape API Improvement
Subject: Inkscape scripting API (Draft)


Return to “General Discussions”