Пример #1
0
def flatten_glider(glider, path):
    # Temporary declarations:
    allowance_general = 0.01
    parts = []

    drawing = dxf.drawing(path)
    drawing.add_layer('MARKS')
    drawing.add_layer('CUTS')

    for cell in glider.cells:
        left, right = flattened_cell(cell)

        left_out = left.copy()
        right_out = right.copy()
        left_out.add_stuff(-allowance_general)
        right_out.add_stuff(allowance_general)

        right_out.data = right_out.data[::-1]
        left_out += right_out
        right.data = right.data[::-1]
        left = left + right

        left.layer = 'MARKS'
        left_out.layer = 'CUTS'

        parts.append([left, left_out])

    startx = 0
    for liste in parts:
        startpoint = [startx + 0.1, 0]
        group = DXFList()
        for element in liste:
            startx = max(startx,
                         startpoint[0] + max([x[0] for x in element.data]))
            group.append(
                dxf.polyline(points=(element.data + startpoint) * 1000,
                             layer=element.layer))
        drawing.add(group)
    drawing.save()
    return True
Пример #2
0
def flatten_glider(glider, path):
    # Temporary declarations:
    allowance_general = 0.01
    glider.recalc()
    parts = []

    drawing = dxf.drawing(path)
    drawing.add_layer('MARKS')
    drawing.add_layer('CUTS')

    for cell in glider.cells:
        left, right = flattened_cell(cell)

        left_out = left.copy()
        right_out = right.copy()
        left_out.add_stuff(-allowance_general)
        right_out.add_stuff(allowance_general)

        right_out.data = right_out.data[::-1]
        left_out += right_out
        right.data = right.data[::-1]
        left = left + right

        left.layer = 'MARKS'
        left_out.layer = 'CUTS'

        parts.append([left, left_out])

    startx = 0
    for liste in parts:
        startpoint = [startx+0.1, 0]
        group = DXFList()
        for element in liste:
            startx = max(startx, startpoint[0]+max([x[0] for x in element.data]))
            group.append(dxf.polyline(points=(element.data+startpoint)*1000, layer=element.layer))
        drawing.add(group)
    drawing.save()
    return True
Пример #3
0
class _DimensionBase(object):
    """ Abstract base class for dimension lines """
    def __init__(self, dimstyle, layer, roundval):
        self.dimstyle = dimstyles.get(dimstyle)
        self.layer = layer
        self.roundval = roundval
        self.data = DXFList()

    def prop(self, property_name):
        """ Get dimension line properties by **property_name** with the
        possibility to override several properties.
        """
        if property_name == 'layer':
            return self.layer if self.layer is not None else self.dimstyle.layer
        elif property_name == 'roundval':
            return self.roundval if self.roundval is not None else self.dimstyle.roundval
        else: # pass through self.dimstyle object DimStyle()
            return self.dimstyle[property_name]

    def _build_dimline(self):
        """ build dimension line object with basic dxf entities """
        raise NotImplementedError("override abstract method _build_dimline")

    def format_dimtext(self, dimvalue):
        """ string format the dimension text """
        ## TODO: concider roundhalf property
        dimtextfmt = "%." + str(self.prop('roundval')) + "f"
        dimtext = dimtextfmt % dimvalue
        if DIMENSIONS_FLOATINGPOINT in dimtext:
            # remove successional zeros
            dimtext.rstrip('0')
            # remove floating point as last char
            dimtext.rstrip(DIMENSIONS_FLOATINGPOINT)
        return self.prop('prefix') + dimtext + self.prop('suffix')

    def __dxf__(self):
        """ get the dxf string """
        self._build_dimline()
        return self.data.__dxf__()
Пример #4
0
 def __init__(self, dimstyle, layer, roundval):
     self.dimstyle = dimstyles.get(dimstyle)
     self.layer = layer
     self.roundval = roundval
     self.data = DXFList()
Пример #5
0
 def __init__(self, dimstyle, layer, roundval):
     self.dimstyle = dimstyles.get(dimstyle)
     self.layer = layer
     self.roundval = roundval
     self.data = DXFList()