예제 #1
0
def main():
    dwg = ezdxf.new('R12')
    for name, desc, pattern in standards.linetypes():
        if name in dwg.linetypes:
            continue
        dwg.linetypes.new(name,
                          dxfattribs={
                              'description': desc,
                              'pattern': pattern,
                          })
    for name, font in standards.styles():
        if name in dwg.styles:
            continue
        dwg.styles.new(name, dxfattribs={
            'font': font,
        })

    msp = dwg.modelspace()
    for n, ltype in enumerate(dwg.linetypes):
        name = ltype.dxf.name
        msp.add_line((0, n), (10, n), dxfattribs={'linetype': name})
        msp.add_text(name,
                     dxfattribs={
                         'insert': (0, n + 0.1),
                         'height': 0.25,
                         'style': 'ARIAL'
                     })
    dwg.saveas('standard_linetypes.dxf')
예제 #2
0
파일: utils.py 프로젝트: kozbot/kecb
def new_dwg():
    dwg = ezdxf.new(dxfversion='AC1015')
    for linetype in std.linetypes():
        try:
            dwg.linetypes.new(name=linetype[0],
                              dxfattribs={
                                  'description': linetype[1],
                                  'pattern': linetype[2]
                              })
        except ValueError as e:
            pass

    return dwg
예제 #3
0
# Copyright (c) 2020 Manfred Moitzi
# License: MIT License
import ezdxf
from ezdxf.tools import standards
from ezdxf.math import Vector
from ezdxf import units

for unit in (1, 6):
    unit_name = units.decode(unit)
    doc = ezdxf.new('R2000', setup=True, units=unit)
    msp = doc.modelspace()

    for y, ltype in enumerate(standards.linetypes()):
        msp.add_line((0, y), (20, y), dxfattribs={'linetype': ltype[0]})
    doc.set_modelspace_vport(25, center=(10, 10))
    doc.saveas(f'linetypes_{unit_name}_lines.dxf')

    doc = ezdxf.new('R2000', setup=True, units=unit)
    msp = doc.modelspace()

    for r, ltype in enumerate(standards.linetypes()):
        msp.add_circle((0, 0), radius=4 + r, dxfattribs={'linetype': ltype[0]})
    doc.set_modelspace_vport(50)
    doc.saveas(f'linetypes_{unit_name}_circle.dxf')

    doc = ezdxf.new('R2000', setup=True, units=unit)
    msp = doc.modelspace()

    points = Vector.list([(0, 0), (4, 9), (6, 9), (11, 0), (16, 9)])
    for y, ltype in enumerate(standards.linetypes()):
        fitpoints = [p + (0, y) for p in points]
예제 #4
0
        (1, (2, 6)),
    ),
    'lines': (
        ((12, 3), (18, 2), 'CONTINUOUS', 'B'),
        ((29, 18), (4, 15), 'DASHED', 'A'),
        ((5, 10), (24, 16), 'DASHED', 'A'),
        ((8, 21), (20, 23), 'HIDDEN', 'B'),
        ((7, 5), (28, 25), 'CONTINUOUS', 'B'),
        ((3, 4), (14, 29), 'CONTINUOUS', 'A'),
        ((11, 13), (16, 3), 'DOTTED', 'A'),
    ),
}

dwg = ezdxf.new('AC1027')  # Version necessary for saving images

for name, desc, pattern in linetypes():
    try:  # you can only create not existing line types
        dwg.linetypes.new(name=name,
                          dxfattribs={
                              'description': desc,
                              'pattern': pattern
                          })
    except ValueError:
        pass  # ignore already existing line types

# Define your own line types:
# dxf linetype definition
# name, description, elements:
# elements = [total_pattern_length, elem1, elem2, ...]
# total_pattern_length = sum(abs(elem))
# elem > 0 is line, < 0 is gap, 0.0 = dot;
예제 #5
0
# Copyright (c) 2019 Manfred Moitzi
# License: MIT License

import ezdxf
from ezdxf.math import Vec3
from ezdxf.tools.standards import linetypes

doc = ezdxf.new('R2007', setup=True)
msp = doc.modelspace()

# How to change the global linetype scaling:
doc.header['$LTSCALE'] = .5

p1 = Vec3(0, 0)
p2 = Vec3(9, 0)
delta = Vec3(0, -1)
text_offset = Vec3(0, .1)

for lt in linetypes():
    name = lt[0]
    msp.add_line(p1, p2, dxfattribs={'linetype': name, 'lineweight': 25})
    msp.add_text(name, dxfattribs={'style': 'OpenSansCondensed-Light', 'height': 0.25}).set_pos(p1+text_offset)
    p1 += delta
    p2 += delta

doc.set_modelspace_vport(25, center=(5, -10))
doc.saveas('all_std_line_types.dxf')