示例#1
0
    def effect(self):
        length = self.unittouu(str(self.options.length) + self.options.unit)
        thickness = self.unittouu(
            str(self.options.thickness) + self.options.unit)
        gap = self.unittouu(str(self.options.gap) + self.options.unit)

        split = self.options.split * 2 + 1

        step = length / split

        t = 'translate(' + str(self.view_center[0]) + ',' + \
            str(self.view_center[1]) + ')'
        g_attribs = {
            inkex.addNS('label', 'inkscape'):
            'Holes' + str(length) + "/" + str(split),
            'transform':
            t
        }
        g = inkex.etree.SubElement(self.current_layer, 'g', g_attribs)

        # Create SVG Path for plate
        style = {
            'stroke': '#000000',
            'fill': 'none',
            'stroke-width': str(self.unittouu('1px'))
        }

        # draw the line
        points = [(0, 0), (length, 0)]
        if self.options.vertical: points = [(b, a) for (a, b) in points]
        path = lc.points_to_svgd(points)

        box_attribs = {'style': formatStyle(style), 'd': path}
        box = inkex.etree.SubElement(g, inkex.addNS('path', 'svg'),
                                     box_attribs)

        # draw the holes
        y = gap
        x = step
        while x < length:
            points = [(x, y), (x, y + thickness), (x + step, y + thickness),
                      (x + step, y), (x, y)]
            if self.options.vertical: points = [(b, a) for (a, b) in points]
            path = lc.points_to_svgd(points)
            box_attribs = {'style': formatStyle(style), 'd': path}
            box = inkex.etree.SubElement(g, inkex.addNS('path', 'svg'),
                                         box_attribs)
            x += step * 2
示例#2
0
文件: lc_box.py 项目: allali/lasercut
    def effect(self):
        width = self.unittouu(str(self.options.width)+self.options.unit)
        height = self.unittouu(str(self.options.height)+self.options.unit)
        thickness = self.unittouu(str(self.options.thickness)+self.options.unit)

        # Create main element
        t = 'translate(' + str(self.view_center[0]) + ',' + \
            str(self.view_center[1]) + ')'
        g_attribs = {
            inkex.addNS('label', 'inkscape'): 'Box' + str(width) + "x"+str(height),
            'transform': t}
        g = inkex.etree.SubElement(self.current_layer, 'g', g_attribs)
        style = {'stroke': '#000000',
                 'fill': 'none',
                 'stroke-width': str(self.unittouu('1px'))}

        # Create path
        points=lc.make_plate((width,height),
                             (self.options.iwidth,self.options.iheight),
                             thickness,self.options.wsplit,self.options.hsplit,
                             self.options.bottom,self.options.bottomshift,
                             self.options.top,self.options.topshift,
                             self.options.left,self.options.leftshift,
                             self.options.right,self.options.rightshift)

        path = lc.points_to_svgd(points)

        
        # Create SVG Path for plate
        box_attribs = {
            'style': formatStyle(style),
            'd': path}
        box = inkex.etree.SubElement(
            g, inkex.addNS('path', 'svg'), box_attribs)    
示例#3
0
    def effect(self):
        length=self.unittouu(str(self.options.length)+self.options.unit)
        thickness=self.unittouu(str(self.options.thickness)+self.options.unit)
        gap=self.unittouu(str(self.options.gap)+self.options.unit)
             
        split=self.options.split * 2+1

        step=length/split
        
        t = 'translate(' + str(self.view_center[0]) + ',' + \
            str(self.view_center[1]) + ')'
        g_attribs = {
            inkex.addNS('label', 'inkscape'): 'Holes' + str(length) + "/"+str(split),
            'transform': t}
        g = inkex.etree.SubElement(self.current_layer, 'g', g_attribs)

        # Create SVG Path for plate
        style = {'stroke': '#000000', 'fill': 'none', 'stroke-width': str(self.unittouu('1px'))}

        # draw the line
        points=[(0,0),(length,0)]
        if self.options.vertical: points=[(b,a) for (a,b) in points]
        path = lc.points_to_svgd(points)        
        
        box_attribs = {
            'style': formatStyle(style),
            'd': path}
        box = inkex.etree.SubElement(
            g, inkex.addNS('path', 'svg'), box_attribs)

        # draw the holes
        y=gap
        x=step
        while x<length:
            points=[(x,y),(x,y+thickness),(x+step,y+thickness),(x+step,y),(x,y)]
            if self.options.vertical: points=[(b,a) for (a,b) in points]
            path = lc.points_to_svgd(points)                
            box_attribs = {
                'style': formatStyle(style),
                'd': path}
            box = inkex.etree.SubElement(
                g, inkex.addNS('path', 'svg'), box_attribs)
            x+=step*2
示例#4
0
    def effect(self):
        width = self.unittouu(str(self.options.width) + self.options.unit)
        height = self.unittouu(str(self.options.height) + self.options.unit)
        thickness = self.unittouu(
            str(self.options.thickness) + self.options.unit)

        # Create main element
        t = 'translate(' + str(self.view_center[0]) + ',' + \
            str(self.view_center[1]) + ')'
        g_attribs = {
            inkex.addNS('label', 'inkscape'):
            'Box' + str(width) + "x" + str(height),
            'transform':
            t
        }
        g = inkex.etree.SubElement(self.current_layer, 'g', g_attribs)
        style = {
            'stroke': '#000000',
            'fill': 'none',
            'stroke-width': str(self.unittouu('1px'))
        }

        # Create path
        points = lc.make_plate(
            (width, height), (self.options.iwidth, self.options.iheight),
            thickness, self.options.wsplit, self.options.hsplit,
            self.options.bottom, self.options.bottomshift, self.options.top,
            self.options.topshift, self.options.left, self.options.leftshift,
            self.options.right, self.options.rightshift)

        path = lc.points_to_svgd(points)

        # Create SVG Path for plate
        box_attribs = {'style': formatStyle(style), 'd': path}
        box = inkex.etree.SubElement(g, inkex.addNS('path', 'svg'),
                                     box_attribs)