Creating Extensions

Post questions on how to use or achieve an effect in Inkscape.
SteveG

Creating Extensions

Postby SteveG » Tue Apr 22, 2008 10:24 am

Attempting to create an extension in Pascal (fpc) and having problems.
Inkscape calls my program correctly (which 'seems' to work ok), but doesnt change anything within Inkscape when it returns (no errors or logs created)
My understanding of the process is -
Inkscape calls my program with 'selection' and 'tmpfilename' on the command line
My program modifies the svg as necessary
My program outputs the changed svg (full file) onto stdout, with an exit code of 0.

As a test, why does the following not work ?
1 - I create an Inkscape file, saved as 'Work1'
2 - I create a copy of 'Work1' and make a minor modification to it - saved as 'Work2'
3 - My extension (inx) file calls 'Test.bat' in the extensions folder
4 - 'Test.bat' has a single line: type Work2

If I open 'Work1' in Inkscape, then run my extension 'Test' (which merely returns the modified 'Work2' on stdout) why doesnt Inkscape update onscreen ?

I'm hoping that the answer to this will also show where I'm going wrong in my pascal program

Thanks heaps for any help on this

User avatar
sas
Posts: 404
Joined: Sat Oct 06, 2007 5:42 am

Re: Creating Extensions

Postby sas » Tue Apr 22, 2008 6:30 pm

SteveG wrote:4 - 'Test.bat' has a single line: type Work2

That won't work, since the batch file will echo the command to stdout before executing it. Have you tried using

@type Work2

to suppress the echo?

SteveG

Re: Creating Extensions

Postby SteveG » Tue Apr 22, 2008 10:39 pm

Thanks sas - works perfectly with the suppression
Now just need to figure why a problem with my pascal program (simple though it is) - but this at least shows its actually possible
sometimes you need to do magic to believe in magic :)

User avatar
sas
Posts: 404
Joined: Sat Oct 06, 2007 5:42 am

Re: Creating Extensions

Postby sas » Wed Apr 23, 2008 1:14 am

Are you sure you've got the command-line arguments right? You can check what they are by writing them to stderr (so that Inkscape will display them after the extension has run). In your Test.bat this can be done by adding the line

@echo %* 1>&2

and no doubt you know how to do it in Pascal.

Have you tried running your Pascal program on its own, with the appropriate command-line arguments, and checking that Inkscape can open the file it produces?

If it works on its own, with the same command-line arguments that Inkscape passes it, then I don't know what can be wrong, unless there's a problem with the .inx file.


Return to “Help with using Inkscape”