From: JazzyNico Date: Thu, 30 Dec 2010 08:08:48 +0000 (+0100) Subject: Extensions. Gear extension with center hole (see Bug #692719, gear extension should... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=3a35bd4d7b01b00e01b13343f9ec3af1c545b981;p=inkscape.git Extensions. Gear extension with center hole (see Bug #692719, gear extension should have option to render a central hole). --- diff --git a/share/extensions/gears.inx b/share/extensions/gears.inx index 8360a3745..ec733fb6b 100644 --- a/share/extensions/gears.inx +++ b/share/extensions/gears.inx @@ -5,8 +5,15 @@ gears.py inkex.py 24 - 20.0 - 20.0 + 20.0 + 20.0 + 20.0 + + <_option value="px">px + <_option value="in">in + <_option value="mm">mm + + Unit of measure for both circular pitch and center diameter. all diff --git a/share/extensions/gears.py b/share/extensions/gears.py index 8f4745423..a1b3ee666 100644 --- a/share/extensions/gears.py +++ b/share/extensions/gears.py @@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import inkex import simplestyle, sys from math import * +import string def involute_intersect_angle(Rb, R): Rb, R = float(Rb), float(R) @@ -55,11 +56,20 @@ class Gears(inkex.Effect): action="store", type="float", dest="angle", default=20.0, help="Pressure Angle (common values: 14.5, 20, 25 degrees)") + self.OptionParser.add_option("-c", "--centerdiameter", + action="store", type="float", + dest="centerdiameter", default=10.0, + help="Diameter of central hole - 0.0 for no hole") + self.OptionParser.add_option("-u", "--unit", + action="store", type="string", + dest="unit", default="px", + help="unit of measure for circular pitch and center diameter") def effect(self): teeth = self.options.teeth - pitch = self.options.pitch + pitch = inkex.unittouu( str(self.options.pitch) + self.options.unit) angle = self.options.angle # Angle of tangent to tooth at circular pitch wrt radial line. + centerdiameter = inkex.unittouu( str(self.options.centerdiameter) + self.options.unit) # print >>sys.stderr, "Teeth: %s\n" % teeth @@ -157,6 +167,15 @@ class Gears(inkex.Effect): style = { 'stroke': '#000000', 'fill': 'none' } gear_attribs = {'style':simplestyle.formatStyle(style), 'd':path} gear = inkex.etree.SubElement(g, inkex.addNS('path','svg'), gear_attribs ) + if(centerdiameter > 0.0): + center_attribs = {'style':simplestyle.formatStyle(style), + inkex.addNS('cx','sodipodi') :'0.0', + inkex.addNS('cy','sodipodi') :'0.0', + inkex.addNS('rx','sodipodi') :str(centerdiameter/2), + inkex.addNS('ry','sodipodi') :str(centerdiameter/2), + inkex.addNS('type','sodipodi') :'arc' + } + center = inkex.etree.SubElement(g, inkex.addNS('path','svg'), center_attribs ) if __name__ == '__main__': e = Gears()