Scripting Extension use.
Scripting Extension use.
How would I go about creating code that made use of the generate from curve extension? Are all the loaded extensions available as methods. Tuff to find much info.
Re: Scripting Extension use.
Welcome to the forum!
Yes, at this time, there is very, very little info available about how to write extensions. You pretty much have to already know the basics. However, there is some precious little info here and there.
One of our members has written a tutorial viewtopic.php?f=34&t=10591. Also in the Inkscape wiki, look at the Developer Documentation section of this page http://wiki.inkscape.org/wiki/index.php/Inkscape.
Yes, at this time, there is very, very little info available about how to write extensions. You pretty much have to already know the basics. However, there is some precious little info here and there.
One of our members has written a tutorial viewtopic.php?f=34&t=10591. Also in the Inkscape wiki, look at the Developer Documentation section of this page http://wiki.inkscape.org/wiki/index.php/Inkscape.
Basics - Help menu > Tutorials
Manual - Inkscape: Guide to a Vector Drawing Program
Inkscape Community - Inkscape FAQ - Gallery
Inkscape for Cutting Design
Manual - Inkscape: Guide to a Vector Drawing Program
Inkscape Community - Inkscape FAQ - Gallery
Inkscape for Cutting Design
Re: Scripting Extension use.
brynn wrote:One of our members has written a tutorial viewtopic.php?f=34&t=10591.
Keep in mind that the mentioned - very informative and detailed - blog article by LiquidAsh addresses a specific use case of the Inkscape extension system: using external custom binaries (C# in this case) with Inkscape extensions on Windows. I failed to get a working solution based on those instructions with Inkscape on Mac OS X (probably due to platform-dependent implementation differences of the python functions used in the py wrapper/stub script communicating with a custom external binary or script).
Re: Scripting Extension use.
inkexit wrote:How would I go about creating code that made use of the generate from curve extension?
Which extension are you referring to? (There is no specific "generate from curve extension" - there are however several listed in 'Extensions > Generate from Path'. The sub-menu 'Generate from Path' is an arbitrary "category" of extensions which use an existing object (path) and manipulate it). Maybe you could ask a more specific question, or describe what you are actually trying to do?
Note: Inkscape extensions are usually cross-platform (if making use of a common scripting language like python), but some details might vary depending on which OS/platform you use for developing, and have in mind for deployment.
With regard to reused code (aka shared modules) in extension scripts:
I would recommend to start with inspecting the script and INX files of the extensions shipping with Inkscape [1]: most of them are python-based, and make use of several provided python modules which offer basic infrastructure and functions to manipulate SVG content / objects: Python modules for extensions.
[1] the files can be viewed
- locally, depending on your OS, in:
linux: '/usr/local/share/inkscape/extensions' (or '/usr/share/inkscape/extensions')
Windows: (Inkscape application directory)\share\extensions
OS X: 'Inkscape.app/Contents/Resources/extensions' (MacPorts: '/opt/local/share/inkscape/extensions') - online - browsing the code repository for Inkscape 0.48.x / development branch
Re: Scripting Extension use.
What I'm trying to do is:
load a curve,
load a shape,
(both the directory path to this curve and it's filename will be hard coded into the code, no need for a dialog box)
run the add points extension to insure there are enough nodes on the surface of the shape
select both the curve and the shape, and run the generate
from path -> pattern along path extension with the single, stretched option, and the snake deformation.
delete the original curve and shape, leaving only the newly generated shape.
Also after this point I would like to do things like create a directory on my computer, save a thumnail png to that directory, and save that svg to that file
rinse, wash, repeat...
(Load a different curve, and a different shape, and run the whole function again, saving to new direstocy with a serial number I iterate++ on each loop.
Seems to me that I am not really trying to write an extension here, but a form of Macro. As in, I'm not really trying to create a fully fledged plugin to be distributed, but only need this for my own work. However I am very new to inkscape coding, maybe the only way to automate anything in inkscape is to develop an extension, ie, there is no "macro" support?
Thanks for all the help you have bee giving guys!
load a curve,
load a shape,
(both the directory path to this curve and it's filename will be hard coded into the code, no need for a dialog box)
run the add points extension to insure there are enough nodes on the surface of the shape
select both the curve and the shape, and run the generate
from path -> pattern along path extension with the single, stretched option, and the snake deformation.
delete the original curve and shape, leaving only the newly generated shape.
Also after this point I would like to do things like create a directory on my computer, save a thumnail png to that directory, and save that svg to that file
rinse, wash, repeat...
(Load a different curve, and a different shape, and run the whole function again, saving to new direstocy with a serial number I iterate++ on each loop.
Seems to me that I am not really trying to write an extension here, but a form of Macro. As in, I'm not really trying to create a fully fledged plugin to be distributed, but only need this for my own work. However I am very new to inkscape coding, maybe the only way to automate anything in inkscape is to develop an extension, ie, there is no "macro" support?
Thanks for all the help you have bee giving guys!
Re: Scripting Extension use.
deleted
Last edited by inkexit on Thu May 03, 2012 2:37 am, edited 2 times in total.
Re: Scripting Extension use.
~suv wrote:failed to get a working solution based on those instructions with Inkscape on Mac OS X
Interesting... I may be getting a Mac sometime in the next few months, and will have to try this out when I do.
Btw, I second ~suv's suggestion of looking through the extensions that come with Inkscape.
Re: Scripting Extension use.
Apologies for the double post.
Could someone write out a short example in code?
I want to run this from the command line, so something like:
launch Inkscape;
open C:/Curves/Curve1.svg;
transform: Curve1: vertical 120%, horizontal 100%;
save new svg document as 'new1';
close document;
close inkscape;
Even this simple example would be of a great help.
I have been reading the examples in the library and am starting to get an understanding of how they work together, but not what an extension script needs to look like overall from beginning to end. For example, I'm sure there must be imports or includes at the beginning of every script?
Thank you.
Could someone write out a short example in code?
I want to run this from the command line, so something like:
launch Inkscape;
open C:/Curves/Curve1.svg;
transform: Curve1: vertical 120%, horizontal 100%;
save new svg document as 'new1';
close document;
close inkscape;
Even this simple example would be of a great help.
I have been reading the examples in the library and am starting to get an understanding of how they work together, but not what an extension script needs to look like overall from beginning to end. For example, I'm sure there must be imports or includes at the beginning of every script?
Thank you.
Re: Scripting Extension use.
LiquidAsh wrote:~suv wrote:failed to get a working solution based on those instructions with Inkscape on Mac OS X
Interesting... I may be getting a Mac sometime in the next few months, and will have to try this out when I do.
Nevermind - AFAICT it was PEBKAC (I was trying to run an executable located in the user extensions directory which I don't have included in $PATH - since it's not needed when e.g. running a shell script directly called from the INX file. Your python module works ok also on Macs if one either specifies the full path to the executable (my quick hack), or otherwise makes sure the executable is located somewhere in $PATH that is currently in effect for Inkscape and the spawned python process (Note: for users of the packaged OS X application, this is not necessarily the same as used in a currently opened terminal window (which might have a custom $PATH based on ~/.bash_profile or ~/.profile)).