Comment 9 for bug 600472

Revision history for this message
DavidTalmage (david-junk-mail) wrote :

Your new fix fixes misplace objects in dxf output for support types.

It does not fix text output
it does not fix rectangle output
if does not address same problem in hpgl output

If you want to support rectangles I found some buggy code in pathmodifier for converting a rectangle to a path. Here is my corrected code.

    def rectToPath(self,node,doReplace=True):
        if node.tag == inkex.addNS('rect','svg'):
            x =float(node.get('x'))
            y =float(node.get('y'))
            try:
                rx=float(node.get('rx'))
            except:
                rx=0
            try:
                ry=float(node.get('ry'))
            except:
                ry=0
            if rx == 0 and ry != 0:
                rx = ry
            if ry == 0 and rx != 0:
                ry = rx
            w =float(node.get('width' ))
            h =float(node.get('height'))
            d ='M %f,%f '%(x+rx,y)
            d+='L %f,%f '%(x+w-rx,y)
            d+='A %f,%f,%i,%i,%i,%f,%f '%(rx,ry,0,0,1,x+w,y+ry)
            d+='L %f,%f '%(x+w,y+h-ry)
            d+='A %f,%f,%i,%i,%i,%f,%f '%(rx,ry,0,0,1,x+w-rx,y+h)
            d+='L %f,%f '%(x+rx,y+h)
            d+='A %f,%f,%i,%i,%i,%f,%f '%(rx,ry,0,0,1,x,y+h-ry)
            d+='L %f,%f '%(x,y+ry)
            d+='A %f,%f,%i,%i,%i,%f,%f '%(rx,ry,0,0,1,x+rx,y)

            newnode=inkex.etree.Element('path')
            newnode.set('d',d)
            newnode.set('id', self.uniqueId('path'))
            newnode.set('style',node.get('style'))
            nnt = node.get('transform')
            if nnt:
                newnode.set('transform',nnt)
                fuseTransform(newnode)
            if doReplace:
                parent=node.getparent()
                parent.insert(parent.index(node),newnode)
                parent.remove(node)
            return newnode