Coordinate system in millimeters

Discussion about writing code for Inkscape.
coper
Posts: 1
Joined: Mon Nov 07, 2016 4:09 am

Coordinate system in millimeters

Postby coper » Mon Nov 07, 2016 5:08 am

Hello, World!

I'm trying to make an extension that will create some shapes and paths and arrange them in specific order. All objects have dimensions specified in millimeters.
Creating square, for example, in millimeters is no problem just by adding + 'mm' to it's parameters. However this trick is not working with paths and translate attribute.
I'm sorry for maybe a silly question, but I'm not an experienced programmer, and any examples will be really helpful

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

Re: Coordinate system in millimeters

Postby Moini » Mon Nov 07, 2016 8:24 am

Hi coper,

I'd suggest you take a look at a couple of other extensions first, and also at the 'simpletransform' and 'simplepath' python modules that come with Inkscape, to find out how to do it. You don't need to reinvent everything from scratch, just take some time to investigate. Select an extension that does something similar like the one you want to write and start from there.

For unit conversion, you could also use the built-in one (something like self.unittouu and the other way around). You can find that used in many of the extensions that Inkscape ships with, and the method lives in inkex.py.
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)

User avatar
prkos
Posts: 1625
Joined: Tue Nov 06, 2007 8:45 am
Location: Croatia

Re: Coordinate system in millimeters

Postby prkos » Mon Nov 07, 2016 8:29 am

In Inkscape you can set default units per document, I expect transforms and other relevant operations would follow that setting, although I haven't checked. There is probably a guideline in Inkscape programming how to handle units.

You'll probably get an answer here, but just in case you don't try emailing the dev mailing list, or asking in #inkscape-devel room on IRC.
just hand over the chocolate and nobody gets hurt

Inkscape Manual on Floss
Inkscape FAQ
very comprehensive Inkscape guide
Inkscape 0.48 Illustrator's Cookbook - 109 recipes to learn and explore Inkscape - with SVG examples to download


Return to “Programming”