#!/usr/bin/env python import sys,inkex class Dots(inkex.Effect): def effect(self): for id, node in self.selected.iteritems(): if node.tagName == 'path': a =[] d = node.attributes.getNamedItem('d') p = inkex.parsePath(d.value) num = 1 for cmd,params in p: a.append(['M',params[-2:]]) a.append(['L',params[-2:]]) self.addText(node,params[-2],params[-1],num) num += 1 d.value = inkex.formatPath(a) style = node.attributes.getNamedItem('style') s = inkex.parseStyle(style.value) s['stroke-linecap']='round' s['stroke-width']='5px' style.value = inkex.formatStyle(s) def addText(self,node,x,y,text): new = self.document.createElement('svg:text') s = {'stroke-linejoin': 'miter', 'font-size': '20', 'stroke-width': '1.0px', 'stroke-opacity': '1.0', 'fill-opacity': '1.0', 'stroke': 'none', 'stroke-linecap': 'butt', 'font-weight': 'normal', 'font-style': 'normal', 'fill': '#000000'} new.setAttribute('style', inkex.formatStyle(s)) new.setAttribute('x', str(x)) new.setAttribute('y', str(y)) #TODO: prevent id collisions? new.setAttribute('id', 'dots'+str(text)) new.appendChild(self.document.createTextNode(str(text))) node.parentNode.appendChild(new) e = Dots() e.affect()