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
Extensions > Render > Cartesian grid units
Re: Extensions > Render > Cartesian grid units
It is an Inkscape script extension written in Python.ottadini wrote:how is the extension coded?
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):ottadini wrote:where is the source?
- 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):
Re: Extensions > Render > Cartesian grid units
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:
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?
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?
Re: Extensions > Render > Cartesian grid units
~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:
- Script extensions - Inkscape Wiki
- Python modules for extensions - Inkscape Wiki
- Generating objects from extensions - Inkscape Wiki
- PythonEffectTutorial - Inkscape Wiki
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.