diff options
| author | Aurelio A. Heckert (a) <auriumgmaildotcom> | 2010-03-03 13:53:15 +0000 |
|---|---|---|
| committer | Aurelio A. Heckert (a) <auriumgmaildotcom> | 2010-03-03 13:53:15 +0000 |
| commit | da7ca578eac6f2c00dd42ebdafbfbfcafc42e7e8 (patch) | |
| tree | 39a4510b4753662983b82413054e56a7c1bad421 /share/extensions/webslicer-create-rect.py | |
| parent | Extensions. Fix bug in svg+media when there are special characters in the path (diff) | |
| download | inkscape-da7ca578eac6f2c00dd42ebdafbfbfcafc42e7e8.tar.gz inkscape-da7ca578eac6f2c00dd42ebdafbfbfcafc42e7e8.zip | |
A little more work to Web Slicer (not usable yet)
(bzr r9135)
Diffstat (limited to 'share/extensions/webslicer-create-rect.py')
| -rwxr-xr-x | share/extensions/webslicer-create-rect.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/share/extensions/webslicer-create-rect.py b/share/extensions/webslicer-create-rect.py index 2c495e7af..9761fd3a5 100755 --- a/share/extensions/webslicer-create-rect.py +++ b/share/extensions/webslicer-create-rect.py @@ -83,12 +83,30 @@ class WebSlicer_CreateRect(inkex.Effect): # inkscape param workarround self.OptionParser.add_option("--tab") + + def unique_slice_name(self): + name = self.options.name + el = self.document.xpath( '//*[@id="'+name+'"]', namespaces=inkex.NSS ) + if len(el) > 0: + if name[-3:] == '-00': name = name[:-3] + num = 0 + num_s = '00' + while len(el) > 0: + num += 1 + num_s = str(num) + if len(num_s)==1 : num_s = '0'+num_s + el = self.document.xpath( '//*[@id="'+name+'-'+num_s+'"]', + namespaces=inkex.NSS ) + self.options.name = name+'-'+num_s + + def effect(self): layer = self.get_slicer_layer() #TODO: get selected elements to define location and size rect = inkex.etree.SubElement(layer, 'rect') if is_empty(self.options.name): - self.options.name = 'rect0001' + self.options.name = 'slice-00' + self.unique_slice_name() rect.set('id', self.options.name) rect.set('fill', 'red') rect.set('opacity', '0.5') |
