Skip to content

Commit

Permalink
Provide pre-defined unit conversions
Browse files Browse the repository at this point in the history
"mm", "cm", "pt", "px", and "inch" all convert to units of "px".
  • Loading branch information
spakin committed Dec 19, 2021
1 parent 6bcd4ec commit 4de5d30
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions simple_inkscape_scripting.py
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,10 @@ def generate(self):
sis_globals['height'] = self.svg.height
sis_globals['svg_root'] = self.svg
sis_globals['print'] = _debug_print
for unit in ['mm', 'cm', 'pt', 'px']:
sis_globals[unit] = inkex.units.convert_unit('1' + unit, 'px')
sis_globals['inch'] = \
inkex.units.convert_unit('1in', 'px') # "in" is a keyword.

# Launch the user's script.
code = ''
Expand Down

0 comments on commit 4de5d30

Please sign in to comment.