First post!
I need to write an extension that will perform the following operations on the selected objects:
(1) take a length as a parameter
(2) for each selected object
(3) Object to Path
(4) Set fill color to none (transparent) and stroke color to black
(5) Set stroke width to the passed parameter
(6) Stroke to Path
(7) Break Apart
(8) Set stroke size to 0.001in ("hairline")
(and some more stuff that I know how to do from an extension)
Steps labeled (3) through (8) I know how to do from menus, but I haven't been able to find how to do backcalls into inkscape from my python code in the extension. It would be really silly to have to re-implement the functionality in python on my own when the code is just sitting in the binary. I suppose I could execute inkscape several times *from* the python script, passing it command-line arguments and temporary files, but there *has* to be a better way, such a callback API, or SWIGed functions, or something.
(What I'm trying to do is have a design that I want to cut on a laser cutter for both figure and ground in contrasting colors, and automatically adjust for kerf).
Help?
Thanks
-
Accessing built-in functionality from an extension?
Re: Accessing built-in functionality from an extension?
There is no way for script-based extensions to access Inkscape's internal functions (the current extension system was not designed this way).gmaker wrote:(…) I haven't been able to find how to do backcalls into inkscape from my python code in the extension.
Inkscape 0.48: Take a look at the extensions which ship with Inkscape - some do call inkscape from the command line for certain operations (Restack, Dimensions, …). There are also several python modules shipping with Inkscape which provide various helper and utility functions for handling paths, transforms and CSS styles in python-based extension scripts.
Roadmap/trunk: The next major release (0.49) will likely include the new dbus-based scripting API (GSoC project from 2009) which will allow access to internal functions and all verbs.
Re: Accessing built-in functionality from an extension?
~suv wrote:There is no way for script-based extensions to access Inkscape's internal functions (the current extension system was not designed this way).gmaker wrote:(…) I haven't been able to find how to do backcalls into inkscape from my python code in the extension.
I suppose the same answer applies to viewtopic.php?f=34&t=12756 ?
Re: Accessing built-in functionality from an extension?
Thanks. I ended up executing inkscape several times from my python script (which is fine). However, because of because of https://bugs.launchpad.net/inkscape/+bug/843260 each invocation takes a while and opens transient windows.
It's still better than doing things by hand!
It's still better than doing things by hand!