summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Dufour <nicoduf@yahoo.fr>2010-12-30 08:08:48 +0000
committerJazzyNico <nicoduf@yahoo.fr>2010-12-30 08:08:48 +0000
commit19129af2095dea8635042359cb15103371f73e83 (patch)
tree4d584aeff67acec26df62f7c09a360476e61af85
parentcheck for element modification before filling undo stack (diff)
downloadinkscape-19129af2095dea8635042359cb15103371f73e83.tar.gz
inkscape-19129af2095dea8635042359cb15103371f73e83.zip
Extensions. Gear extension with center hole (see Bug #692719, gear extension should have option to render a central hole).
(bzr r9992)
-rw-r--r--share/extensions/gears.inx11
-rw-r--r--share/extensions/gears.py21
2 files changed, 29 insertions, 3 deletions
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 @@
<dependency type="executable" location="extensions">gears.py</dependency>
<dependency type="executable" location="extensions">inkex.py</dependency>
<param name="teeth" type="int" min="6" max="360" _gui-text="Number of teeth:">24</param>
- <param name="pitch" type="float" min="0.0" max="1000.0" _gui-text="Circular pitch (px):">20.0</param>
- <param name="angle" type="float" min="10.0" max="30.0" _gui-text="Pressure angle:">20.0</param>
+ <param name="pitch" type="float" min="0.0" max="1000.0" _gui-text="Circular pitch (tooth size):">20.0</param>
+ <param name="angle" type="float" min="10.0" max="30.0" _gui-text="Pressure angle (degrees):">20.0</param>
+ <param name="centerdiameter" type="float" min="0.0" max="1000.0" _gui-text="Diameter of center hole (0 for none):">20.0</param>
+ <param name="unit" _gui-text="Units:" type="optiongroup" appearance="minimal">
+ <_option value="px">px</_option>
+ <_option value="in">in</_option>
+ <_option value="mm">mm</_option>
+ </param>
+ <param name="unit_text" type="description">Unit of measure for both circular pitch and center diameter.</param>
<effect>
<object-type>all</object-type>
<effects-menu>
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()