Inkscape Extension implementation difficulties

Post questions on how to use or achieve an effect in Inkscape.
User avatar
seeminglee
Posts: 6
Joined: Sun Jun 21, 2009 8:24 pm
Location: New York City
Contact:

Inkscape Extension implementation difficulties

Postby seeminglee » Fri Jul 03, 2009 1:00 pm

Hi,

I've been trying to write my Inkscape extensions but kept on getting dependency errors when I try to run it. I'm wondering if anyone can help me out? My code and error message below:

~/.inkscape/extensions/clear_all_guides.inx

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension>
    <_name>Clear all guides</_name>
    <id>sml.inkex.guides.clear</id>
    <dependency type="executable" location="extenions">clear_all_guides.py</dependency>
    <dependency type="executable" location="extenions">inkex.py</dependency>
    <effect>
        <object-type>all</object-type>
        <effects-menu>
            <submenu _name="SML" />
        </effects-menu>
        <script>
            <command reldir="extensions" interpreter="python">clear_all_guides.py</command>
        </script>
    </effect>
</inkscape-extension>


~/.inkscape/extensions/clear_all_guides.py

Code: Select all

#!/usr/bin/env python
'''
Inkscape Extension: Remove all the guides in the document.

'''

import sys
sys.path.append('/usr/share/inkscape/extensions')

import inkex

class ClearAllGuidesEffect(inkex.Effect):

    def __init__(self):
        inkex.Effect.__init__(self)
       
    def effect(self):
       
        namedview = self.document.xpath('/svg:svg/sodipodi:namedview', namespaces=inkex.NSS)
       
        if namedview:
            for node in self.document.xpath('/svg:svg/sodipodi:namedview/sodipodi:guide', namespaces=inkex.NSS):
                parent = node.getparent()
                parent.remove(node)
               
effect = ClearAllGuidesEffect()
effect.affect()


~/.inkscape/extension-errors.log

Code: Select all

Extension "Clear all guides" failed to load because a dependency was not met.
Dependency:
  type: executable
  location: path
  string: clear_all_guides.py

Extension "Clear all guides" failed to load because a dependency was not met.
Dependency:
  type: executable
  location: path
  string: inkex.py


As an fyi, the menu "SML" does show up on the extension menu, though the "Clear all guides" menu item does not - so I know that Inkscape does see my files which makes it all the more curious why the files 'failed to load'.

Any help would be greatly appreciated!

Thanks in advance,
See-ming

User avatar
aho
Posts: 180
Joined: Sun Nov 04, 2007 9:51 am
Contact:

Re: Inkscape Extension implementation difficulties

Postby aho » Fri Jul 03, 2009 3:19 pm

Pretty weird. Inkscape finds your inx, but fails to find the py. Interestingly it also fails to find inkex.py.

Hum. Do other extensions work?

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

Re: Inkscape Extension implementation difficulties

Postby ~suv » Fri Jul 03, 2009 8:02 pm

just a typo in 'clear_all_guides.inx':

s/extenions/extensions/

and no more extension-errors.log messages ;-)

[edit] menu entry is ok, but no guides are cleared, even when I adapt the absolute path reference in the python file to my system (on OS X 10.5.7, there are no inkscape files installed in '/usr/share') [/edit]
Last edited by ~suv on Fri Jul 03, 2009 8:23 pm, edited 1 time in total.

User avatar
seeminglee
Posts: 6
Joined: Sun Jun 21, 2009 8:24 pm
Location: New York City
Contact:

Re: Inkscape Extension implementation difficulties

Postby seeminglee » Fri Jul 03, 2009 8:19 pm

Thank you so much for spotting my silly mistakes!

...which I'd add that it'll more easily avoidable if there's an XML schema (or perhaps a DTD) which would allow me to validate against in the future :)

Cheers,
See-ming

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

Re: Inkscape Extension implementation difficulties

Postby ~suv » Fri Jul 03, 2009 8:29 pm

there is one for Relax NG. Does inkscape.extension.rng work for you? I remember it mentioned when scanning the archives of the inkscape-devel mailinglist

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

Re: Inkscape Extension implementation difficulties

Postby ~suv » Fri Jul 03, 2009 8:35 pm

From: Marcin Floryan <mfloryan@...>
Subject: Extensions (inx) files
Newsgroups: gmane.comp.graphics.inkscape.devel
Date: 2008-04-15 13:12:37 GMT (1 year, 11 weeks, 1 day, 15 hours and 21 minutes ago)

http://thread.gmane.org/gmane.comp.graphics.inkscape.devel/26105

User avatar
seeminglee
Posts: 6
Joined: Sun Jun 21, 2009 8:24 pm
Location: New York City
Contact:

Re: Inkscape Extension implementation difficulties

Postby seeminglee » Fri Jul 03, 2009 9:00 pm

awesome--and thanks for the quick reply.

I'm currently using Eclipse so until I hunt down a relaxng xml validation plugin, the devel thread from your last post definitely helps!

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

Re: Inkscape Extension implementation difficulties

Postby ~suv » Fri Jul 03, 2009 10:15 pm

The xml hint was kindof a random shot - I've no skills in that aera, and reading about it only gave me some abstract understanding... Glad it makes more sense to you ;-)

btw - have you seen or tried the Inkscape Extension: Remove Guides from heathenx?

User avatar
heathenx
Posts: 388
Joined: Thu Jun 07, 2007 11:51 pm
Location: USA
Contact:

Re: Inkscape Extension implementation difficulties

Postby heathenx » Fri Jul 03, 2009 11:40 pm

I just wrote a similar extension about a month ago. My extension removes (deletes) all guides at once. Have a look. :)

http://screencasters.heathenx.org/blog/ ... ve-guides/

User avatar
seeminglee
Posts: 6
Joined: Sun Jun 21, 2009 8:24 pm
Location: New York City
Contact:

Re: Inkscape Extension implementation difficulties

Postby seeminglee » Sat Jul 04, 2009 9:42 pm

Thanks for the link to heathenx' extension -- which helped me figure out:

    * why it's still not working after fixing the typo
    * sys path requirements for all platforms
    * more efficient xpath implementation

All good stuff--in addition to finding interesting stuff on the blog :)

Cheers,
See-ming

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

Re: Inkscape Extension implementation difficulties

Postby ~suv » Sun Jul 05, 2009 7:01 pm

There's a new extension called 'Guides Creator' included in the upcoming 0.47 (and current dev builds), which - besides offering different presets for the creation of guides - also has the option to remove all existing guides.

project home page: inkscape-guides-creator


Return to “Help with using Inkscape”