def dimstyle():
    doc = Drawing.new()
    doc.blocks.new('left_arrow')
    doc.blocks.new('right_arrow')
    doc.blocks.new('arrow')
    doc.blocks.new('_DOT')
    doc.blocks.new('_OPEN')
    return DimStyle.new('FFFF', doc=doc, dxfattribs={
        'name': 'DIMSTYLE1',
    })
Example #2
0
def new(dxfversion: str = DXF2013,
        setup: Union[str, bool, Sequence[str]] = None) -> 'Drawing':
    """
    Create a new :class:`~ezdxf.drawing.Drawing` from scratch, `dxfversion` can be either ``'AC1009'`` the official DXF
    version name or ``'R12'`` the AutoCAD release name.

    :func:`new` can create drawings for following DXF versions:

    ======= ========================
    Version AutoCAD Release
    ======= ========================
    AC1009  AutoCAD R12
    AC1015  AutoCAD R2000
    AC1018  AutoCAD R2004
    AC1021  AutoCAD R2007
    AC1024  AutoCAD R2010
    AC1027  AutoCAD R2013
    AC1032  AutoCAD R2018
    ======= ========================

    .. versionadded:: 0.7.4

         release name as DXF version

    Args:
        dxfversion: DXF version specifier as string, default is ``'AC1027'`` (R2013)
        setup: setup drawing standard styles

                   - ``None`` or ``False`` for no setup
                   - ``'all'`` or ``True`` to setup everything
                   - a list of topics as strings, e.g. ``['linetypes', 'styles']`` to setup only linetypes and text styles:

               ====================== ======================================================
               ``linetypes``          setup line types
               ``styles``             setup text styles
               ``dimstyles``          setup all dimension styles
               ``dimstyles:metric``   setup metric dimension styles
               ``dimstyles:imperial`` setup imperial dimension styles (not implemented yet)
               ``visualstyles``       setup 25 standard visual styles
               ====================== ======================================================

    """
    doc = Drawing.new(dxfversion)
    if setup:
        setup_drawing(doc, topics=setup)
    return doc
Example #3
0
def new(dxfversion='AC1009'):
    """
    Create a new DXF drawing.

    new() can create drawings for following DXF versions:

    - AC1009 or R12: AutoCAD R12 (DXF R12)
    - AC1015 or R2000: AutoCAD 2000 (DXF R2000)
    - AC1018 or R2004: AutoCAD 2004 (DXF R2004)
    - AC1021 or R2007: AutoCAD 2007 (DXF R2007)
    - AC1024 or R2010: AutoCAD 2010 (DXF R2010)
    - AC1027 or R2013: AutoCAD 2013 (DXF R2013)
    - AC1032 or R2018: AutoCAD 2018 (DXF R2018)

    Args:
        dxfversion: DXF version specifier, default is AC1009

    """
    dwg = Drawing.new(dxfversion)
    if dwg.dxfversion > 'AC1009':
        dwg.reset_fingerprintguid()
        dwg.reset_versionguid()
    return dwg
def dwg_r2000():
    return Drawing.new('AC1015')
def dwg_r12():
    return Drawing.new('AC1009')
Example #6
0
# Purpose: test drawing
# Created: 12.03.2011
# Copyright (C) 2011, Manfred Moitzi
# License: MIT License
from __future__ import unicode_literals

import unittest

from ezdxf.tags import StringIterator

from ezdxf.drawing import Drawing
from ezdxf.templatefinder import TemplateFinder
from ezdxf import is_dxf_file


DWG12 = Drawing.new('AC1009')


class TestDrawing(unittest.TestCase):
    def test_dxfversion(self):
        dwg = Drawing(StringIterator(TEST_HEADER))
        self.assertEqual('AC1009', dwg.dxfversion)


class TestNewDrawingAC1009(unittest.TestCase):
    def setUp(self):
        self.dwg = DWG12

    def test_get_layer(self):
        layer = self.dwg.layers.get('0')
        self.assertEqual('0', layer.dxf.name)
Example #7
0
# Author:  mozman -- <*****@*****.**>
# Purpose: test drawing
# Created: 12.03.2011
# Copyright (C) 2011, Manfred Moitzi
# License: MIT License
from __future__ import unicode_literals

import unittest

from ezdxf.tags import StringIterator

from ezdxf.drawing import Drawing
from ezdxf.templatefinder import TemplateFinder
from ezdxf import is_dxf_file

DWG12 = Drawing.new('AC1009')


class TestDrawing(unittest.TestCase):
    def test_dxfversion(self):
        dwg = Drawing(StringIterator(TEST_HEADER))
        self.assertEqual('AC1009', dwg.dxfversion)


class TestNewDrawingAC1009(unittest.TestCase):
    def setUp(self):
        self.dwg = DWG12

    def test_get_layer(self):
        layer = self.dwg.layers.get('0')
        self.assertEqual('0', layer.dxf.name)
def doc():
    return Drawing.new('r2018')