Is it possible to create custom tool (like XML Editor or Object Properties) and few other questions?

Discussion about writing code for Inkscape.
dullman
Posts: 2
Joined: Mon Mar 21, 2016 6:07 pm

Is it possible to create custom tool (like XML Editor or Object Properties) and few other questions?

Postby dullman » Mon Mar 21, 2016 6:53 pm

Hello i'm quite new to inkscape, but since i decided to use in my game vector based characters i created few extension which help me with creating and exporting to different svgs. But truthfully what i need is to tag nodes on path (to know by game which nodes can be modified by different operations), so i would like to create some graphic tool which adds a custom attributes to path object for selected node/nodes (by nodes i mean points that make up path not nodes in xml tree), so i would like to know if it is possible to create some extension and forward me to some example (or extensions that make it), if it's not possible is there any way to get information identifying selected node(s) on path to extension based on effect class (i mean other than using console output since i have a problem with extension running too long).

Also i had a question about running command line in windows, if i run

Code: Select all

inkscape --verb=SOMEVERB somefile.svg
inkscape --verb=SOMEVERB 'somefile.svg somefile2.svg'
it runs fine but if i had a space in file path than running it like that doesn't work

Code: Select all

inkscape --verb=SOMEVERB "somefile withSpace.svg"
inkscape --verb=SOMEVERB '"somefile withSpace.svg.svg" "somefile withSpace2.svg"'
it just return me that file doesn't exists it can be fixed by using -f="somefile with Spaces.svg" but it's only for single file, so it is possible to run command for multiple files with spaces in paths other than creating multiple inkscape command for single files?? (I believe in this case it should run faster since opening inkscape is omitted).

As for next question i want to ask if inkscape has some mechanism which stop running extension (my own python file) if it takes more than few second (probably about 5 but never take) because if extension is running more than 5 sec the cursor change form loading/waiting to normal one and inkscape hangs and stop responding so i need to close it manually?

As for next question in my svg i use an embed css stylesheet and when using command line i see a lot of warnings about properties of styles being non-useful and whilst there exist option in preferences that it would remove but even in checked i don't see any effect on it?

And the last question i want to know if there is any way to get a bounding box for path which isn't based on query to commandLine, i ask because if i could just get a bounding box that i could omit batch files and just fast create svg files through script and i believe it would be thousand times faster than using command line

Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: Is it possible to create custom tool (like XML Editor or Object Properties) and few other questions?

Postby Moini » Tue Mar 22, 2016 3:52 am

Single nodes in extensions:

There's a patch for the developer version of Inkscape that provides an API to select nodes for using them with extensions.
See https://bugs.launchpad.net/inkscape/+bug/1545095 and linked bugs.

Spaces in file names
> so it is possible to run command for multiple files with spaces in paths other than creating multiple inkscape command for single file?

You can:

- use Inkscape in interactive shell mode, to issue a single command per file, and not restart it every time
- rename your files
- try out if single quotes will help 'file one.svg' 'file two.svg' (I seem to remember that there's something special about single quotes on the command line, but it's just a vague idea) - read up on your shell docs, this is probably not an inkscape issue.

Running time:
> As for next question i want to ask if inkscape has some mechanism which stop running extension (my own python file) if it takes more than few second?

- You could write an extension that uses threading, and stops other threads when a certain amount of time has been exceeded. But to be honest, this sounds as if your extension is broken, and maybe looping.

Stylesheet: sorry, can you rephrase this?

Bounding box: look into simpletransform.py, line 192 (and extensions that use it) - it's not exact, but does not require to start a second instance.
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)

dullman
Posts: 2
Joined: Mon Mar 21, 2016 6:07 pm

Re: Is it possible to create custom tool (like XML Editor or Object Properties) and few other questions?

Postby dullman » Tue Mar 22, 2016 4:32 pm

As for patch from what i see i only need to modify python files??

As for spaces in file names, truthfully first i tried to use command from shell but it showed error on --verb that it's need to be run with gui.

As for Running time, no i'm certain that it's not a problem with my extensions, since i use for .. in loop so it could hardly be made into infinite loop (truthfully the only way i can think now is calling recursive method), and even if it was case i checked with few commands to command line inkscape and it showed that it only works for few commands until it hang on (sometimes extension not hang for one command and sometimes for even fourth).

"warnings about properties of styles being non-useful" it's the warnings that shows in command line, there is an option in inkscape prefereces Non-useful style properties which has two checkbox for show warnings and remove style properties, whilst the first one seems working than the second one option seems to do nothing for my svg, it doesn't matter if i save through gui or through command line.

about simpletransform.py i also see this but basically it don't get any bounding box for objects but i will experiment more with this.


Return to “Programming”