Pass current filename to script extension

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

Pass current filename to script extension

Postby DexterMagnific » Sat Jun 21, 2008 12:56 am

Hi,

I have created an extension description which should call a shell script with the current filename.
I have troubles passing the filename.
Here is the description :

Code: Select all

<inkscape-extension>                                                           
    <_name>DANAH::GenerateMap</_name>                                           
    <id>org.danah.transform.map</id>                                           
    <dependency type="executable" location="extensions">danah-apply-transform.s\
h</dependency>                                                                 
    <effect>                                                                   
      <effects-menu>                                                           
        <submenu _name="DANAH"/>                                               
      </effects-menu>                                                           
    </effect>                                                                   
    <script>                                                                   
        <command reldir="extensions">danah-apply-transform.sh ~/thesis/src/transform/svg2gml.xsl</command>                                                     
    </script>                                                                   
</inkscape-extension>


What i want is Inkscape to add the current filename at the end of the command.
How can I make this work ?

Thanks

User avatar
kelan
Posts: 178
Joined: Thu Sep 06, 2007 12:55 am
Location: Unicorn of Open Source
Contact:

Re: Pass current filename to script extension

Postby kelan » Tue Jun 24, 2008 1:27 am

You're asking how to get the filename into the XML description file? I don't think you can do that. The XML description file (.inx) is just a static XML file. On the other hand, if you're asking how to access the filename from within your script, Inkscape should pass it as a regular argument. Try adding some debugging lines to your script that print out the command line arguments. I think you'll see that one of them is the filename. (The filename will look odd because it's a temporary file that Inkscape creates to call the script on.)

pelle
Posts: 53
Joined: Wed Mar 05, 2008 8:23 am

Re: Pass current filename to script extension

Postby pelle » Tue Jun 24, 2008 5:06 am

I would find it very useful if the script could get the full path to the original file. Perhaps it could be added like a special parameter defined in the inx file? Several people have had problems using one of my effects since they have to input the name of another file, a file that is usually in the same folder as the SVG file, but now the users have to input the full absolute path anyway (or make sure Inkscape has the directory of the SVG file as 'current directory', which seems to be a bit too complicated to many users unfortunately).

Having the filename itself seems a bit less useful as you don't even know for sure that the file has been saved recently, so it may not contain the same things as the input to the file.


Return to “Help with using Inkscape”