Extensions > Render > Cartesian grid units

Post questions on how to use or achieve an effect in Inkscape.
User avatar
ottadini
Posts: 34
Joined: Thu Sep 24, 2009 4:27 pm
Location: Australia

Extensions > Render > Cartesian grid units

Postby ottadini » Tue Jun 22, 2010 5:27 pm

Hi,

I have spent a good bit of time trying to find any information about this extension. It's only able to create a cartesian grid with units in pixels. Is it a simple job to allow also the creation of grids in the document default units? any other fixed units?

preferably, and sensibly (to me) it would be more obvious that the extension creates a grid in the default document units, with a choice of other units in some sort of drop-down.

i would add this as a feature request, but i don't really know where best to put it.

how is the extension coded? where is the source? sorry for stupid questions, i have tried to find out, but i've been spinning my wheels for ages with no result.

ben

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

Re: Extensions > Render > Cartesian grid units

Postby ~suv » Tue Jun 22, 2010 6:36 pm

ottadini wrote:how is the extension coded?
It is an Inkscape script extension written in Python.

ottadini wrote:where is the source?
The files grid_cartesian.inx and grid_cartesian.py are in the shared extensions directory of Inkscape. The default location depends on your platform (and might differ from your local installation):
  • linux: /usr/share/inkscape/extensions
  • Windows: C:\Program Files\Inkscape\share\extensions
  • osx: /Applications/Inkscape.app/Contents/Resources/extensions

Links to the files in the 0.47 branch:

Links to the files in the current 0.48 development branch (trunk):

User avatar
ottadini
Posts: 34
Joined: Thu Sep 24, 2009 4:27 pm
Location: Australia

Re: Extensions > Render > Cartesian grid units

Postby ottadini » Thu Jun 24, 2010 4:50 pm

Interesting, I've had a look into the code, and think I get it. I suppose I'll need to understand the inkscape coordinate space first, then work out ways to convert between pixels and scaled units - is the default resolution 90dpi? In the program settings it talks about default export resolution, but is that the system's/application's internal resolution as well?
how do you get document resolution settings? Am i even asking the right question?

so one pixel then is 1/90*25.4 millimetres, = 0.282222222mm, wicked that's a nice round number.

BTW, there's one class, and it's called Grid_Polar! Is that because it was originally just copied from grid_polar.py? i've heard of lazy coders... :)

I also don't really understand how the very last line works:

Code: Select all

if __name__ == '__main__':
    e = Grid_Polar()
    e.affect()

In the class Grid_Polar, the two defs are __init__ and "effect", yet the call at the bottom is to "affect". I'm missing something obvious aren't i?

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

Re: Extensions > Render > Cartesian grid units

Postby ~suv » Thu Jun 24, 2010 5:22 pm

~suv wrote:In the class Grid_Polar, the two defs are __init__ and "effect", yet the call at the bottom is to "affect".

'affect()' is defined in inkex.py:

Code: Select all

    def affect(self, args=sys.argv[1:], output=True):
        """Affect an SVG document with a callback effect"""
        self.svg_file = args[-1]
        self.getoptions(args)
        self.parse()
        self.getposinlayer()
        self.getselected()
        self.getdocids()
        self.effect()
        if output: self.output()



The same file has also some routines for units conversion. For further information about Inkscape script extensions, these wiki pages might be helpful:Other extensions like e.g. 'Visualize Path > Measure Path' might be useful to figure out how to handle different units.

ottadini wrote:is the default resolution 90dpi?

Yes. At the moment this is hard-coded, based on an earlier version of the CSS specification [link], but possibly changes in future versions to 96dpi (current SVG/CSS spec?) or be configurable.


Return to “Help with using Inkscape”