Support unit of measure for render gears and render gear rack plugins

Bug #1408968 reported by Anton
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
New
Wishlist
Unassigned

Bug Description

Hello,

Currently Render gears (and Render gears rack, which I can see appeared in trunk) only allow to provide size parameters in pixels. It would be nice if they allow to provide parameters in any units (physical units like millimeters are useful for CNC).

Plugin files in trunk:
http://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/view/head:/share/extensions/render_gear_rack.inx
http://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/view/head:/share/extensions/render_gear_rack.py
http://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/view/head:/share/extensions/render_gears.inx
http://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/view/head:/share/extensions/render_gears.py

I have implemented this in my own repository (fixed "generate gears" plugin from current stable 0.48, render rack and pinion based on the same "generate gears"):

https://github.com/1i7/metalrobot/blob/master/inkscape/extensions/rack_and_pinion.inx
https://github.com/1i7/metalrobot/blob/master/inkscape/extensions/rack_and_pinion.py
https://github.com/1i7/metalrobot/blob/master/inkscape/extensions/gears1.inx
https://github.com/1i7/metalrobot/blob/master/inkscape/extensions/gears1.py

To add unit of measure take 2 steps:

1) add "Unit" param to inx file:

 <param name="unit" type="optiongroup" appearance="minimal" _gui-text="Unit">
<option value="cm">cm</option>
<option value="ft">ft</option>
<option value="in">in</option>
<option value="m">m</option>
<option value="mm">mm</option>
<option value="pc">pc</option>
<option value="pt">pt</option>
<option value="px">px</option>
</param>

2) then in Python file add unit param to OptionParser

 self.OptionParser.add_option("-u", "--unit",
action="store", type="string",
dest="unit", default="px",
help="The unit of dimensions")

and init other params using this unit in the following way:

 pitch = inkex.unittouu( str(self.options.pitch) + self.options.unit )

With this I have gears and rack and pinion plugins, that can generate details in millimeters in Inkscape 0.48

To test plugins with current Inkscape installation put inx and py files to
- on Windows: C:\Users\user\AppData\Roaming\inkscape\extensions
- on Linux: ~/.config/inkscape/extensions

and restart Inkscape, then go to menu "Extensions/Render/Gear1..." or "Extensions/Render/Rack and pinion...".

Anton (benderamp)
description: updated
Revision history for this message
su_v (suv-lp) wrote :

There are no further bug-fix releases of Inkscape 0.48.x planned.

> pitch = inkex.unittouu( str(self.options.pitch) + self.options.unit )

Please note: using 'inkex.unittouu()' is not compatible with trunk or upcoming 0.91 [1].

Any chance you could coordinate your proposed changes with the author of this (likely) related request?
- Bug #1295641 “gears-dev -- an improved version of the gears extension”
  <https://bugs.launchpad.net/inkscape/+bug/1295641>

--
[1] http://wiki.inkscape.org/wiki/index.php/Release_notes/0.91#Units:_Breaking_change

tags: added: extensions-plugins
Changed in inkscape:
importance: Undecided → Wishlist
Revision history for this message
Anton (benderamp) wrote :

Thank's for pointing, as far, as I can see, this gears-dev project already has unit parameters inside its inx config files.

description: updated
Revision history for this message
Neon22 (neon22) wrote :

Yes - gears-dev does do this much better.

This issue could probably be closed.

Ideally gears-dev could be distributed instead of gears. However new addons page on inkscape.org website does allow easier access to all user made extensions.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.