コード例 #1
0
# Created 2019-02-15
from typing import TYPE_CHECKING
from ezdxf.math import Vector
from ezdxf.lldxf.attributes import DXFAttr, DXFAttributes, DefSubclass, XType
from ezdxf.lldxf.const import DXF12, SUBCLASS_MARKER
from .dxfentity import base_class, SubclassProcessor
from .dxfgfx import DXFGraphic, acdb_entity
from .factory import register_entity

if TYPE_CHECKING:
    from ezdxf.eztypes import TagWriter, DXFNamespace

__all__ = ['Circle']

acdb_circle = DefSubclass('AcDbCircle', {
    'center': DXFAttr(10, xtype=XType.point3d, default=Vector(0, 0, 0)),
    'radius': DXFAttr(40, default=1),
    'thickness': DXFAttr(39, default=0, optional=True),
    'extrusion': DXFAttr(210, xtype=XType.point3d, default=(0, 0, 1), optional=True),
})


@register_entity
class Circle(DXFGraphic):
    """ DXF CIRCLE entity """
    DXFTYPE = 'CIRCLE'
    DXFATTRIBS = DXFAttributes(base_class, acdb_entity, acdb_circle)

    def load_dxf_attribs(self, processor: SubclassProcessor = None) -> 'DXFNamespace':
        dxf = super().load_dxf_attribs(processor)
        if processor:
コード例 #2
0
ファイル: light.py プロジェクト: vshu3000/ezdxf
from typing import TYPE_CHECKING
from ezdxf.lldxf.const import SUBCLASS_MARKER, DXF2007
from ezdxf.lldxf.attributes import DXFAttributes, DefSubclass, DXFAttr, XType
from .dxfentity import base_class, SubclassProcessor
from .dxfgfx import acdb_entity, DXFGraphic
from .factory import register_entity

if TYPE_CHECKING:
    from ezdxf.eztypes import TagWriter, DXFNamespace, UCS

__all__ = ['Light']

acdb_light = DefSubclass(
    'AcDbLight',
    {
        'version': DXFAttr(90, default=0),  # Version number
        'name': DXFAttr(1, default=''),  # Light name
        'type': DXFAttr(70,
                        default=1),  # Light type: 1=distant; 2=point; 3=spot;
        'status': DXFAttr(290, default=1),  # on/off ???
        'plot_glyph': DXFAttr(291, default=0),  # no/yes
        'intensity': DXFAttr(40, default=1),
        'location': DXFAttr(10, xtype=XType.point3d),  # Light position
        'target': DXFAttr(11, xtype=XType.point3d),  # Target location
        'attenuation_type': DXFAttr(72, default=2),  # Attenuation type:
        # 0 = None
        # 1 = Inverse Linear
        # 2 = Inverse Square
        'use_attenuation_limits': DXFAttr(292,
                                          default=0),  # Use attenuation limits
        'attenuation_start_limits': DXFAttr(41),  # Attenuation start limit
コード例 #3
0
ファイル: view.py プロジェクト: kloppen/ezdxf
from ezdxf.entities.dxfentity import base_class, SubclassProcessor, DXFEntity
from ezdxf.entities.layer import acdb_symbol_table_record
from .factory import register_entity

logger = logging.getLogger('ezdxf')

if TYPE_CHECKING:
    from ezdxf.eztypes import TagWriter, DXFNamespace

__all__ = ['View']

acdb_view = DefSubclass(
    'AcDbViewTableRecord',
    {
        'name':
        DXFAttr(2, validator=validator.is_valid_table_name),
        'flags':
        DXFAttr(70, default=0),
        'height':
        DXFAttr(40, default=1),
        'width':
        DXFAttr(41, default=1),
        'center':
        DXFAttr(10, xtype=XType.point2d, default=NULLVEC),
        'direction':
        DXFAttr(
            11,
            xtype=XType.point3d,
            default=Vector(1, 1, 1),
            validator=validator.is_not_null_vector,
        ),
コード例 #4
0
ファイル: geodata.py プロジェクト: yening2020/ezdxf
from .dxfobj import DXFObject
from .factory import register_entity
from .. import units

if TYPE_CHECKING:
    from ezdxf.eztypes import TagWriter, DXFNamespace

__all__ = ['GeoData', 'MeshVertices']

acdb_geo_data = DefSubclass(
    'AcDbGeoData',
    {
        # 1 = R2009, but this release has no DXF version,
        # 2 = R2010
        'version':
        DXFAttr(90, default=2),

        # Handle to host block table record
        'block_record_handle':
        DXFAttr(330, default='0'),

        # 0 = unknown
        # 1 = local grid
        # 2 = projected grid
        # 3 = geographic (latitude/longitude)
        'coordinate_type':
        DXFAttr(
            70,
            default=3,
            validator=validator.is_in_integer_range(0, 4),
            fixer=RETURN_DEFAULT,
コード例 #5
0
    DXFTYPE = 'ACDBPLACEHOLDER'


acdb_xrecord = DefSubclass(
    'AcDbXrecord',
    {
        # 0 = not applicable
        # 1 = keep existing
        # 2 = use clone
        # 3 = <xref>$0$<name>
        # 4 = $0$<name>
        # 5 = Unmangle name
        'cloning':
        DXFAttr(
            280,
            default=1,
            validator=validator.is_in_integer_range(0, 6),
            fixer=RETURN_DEFAULT,
        ),
    })


def totags(tags: Iterable) -> Iterable[DXFTag]:
    for tag in tags:
        if isinstance(tag, DXFTag):
            yield tag
        else:
            yield dxftag(tag[0], tag[1])


@register_entity
class XRecord(DXFObject):
コード例 #6
0
)
from ezdxf.lldxf.const import SUBCLASS_MARKER, DXF2000
from ezdxf.math import NULLVEC, Z_AXIS, X_AXIS
from ezdxf.math.transformtools import transform_extrusion
from .dxfentity import base_class, SubclassProcessor
from .dxfgfx import DXFGraphic, acdb_entity
from .factory import register_entity

if TYPE_CHECKING:
    from ezdxf.eztypes import TagWriter, DXFNamespace, Matrix44

__all__ = ['Tolerance']

acdb_tolerance = DefSubclass('AcDbFcf', {
    'dimstyle': DXFAttr(
        3, default='Standard',
        validator=validator.is_valid_table_name,
    ),
    # Insertion point (in WCS):
    'insert': DXFAttr(10, xtype=XType.point3d, default=NULLVEC),

    # String representing the visual representation of the tolerance:
    'content': DXFAttr(1, default=""),
    'extrusion': DXFAttr(
        210, xtype=XType.point3d, default=Z_AXIS, optional=True,
        validator=validator.is_not_null_vector,
        fixer=RETURN_DEFAULT,
    ),
    # X-axis direction vector (in WCS):
    'x_axis_vector': DXFAttr(
        11, xtype=XType.point3d, default=X_AXIS,
        validator=validator.is_not_null_vector,
コード例 #7
0
ファイル: dimension.py プロジェクト: mbway/ezdxf
from .dxfentity import base_class, SubclassProcessor
from .dxfgfx import DXFGraphic, acdb_entity
from .factory import register_entity
from .dimstyleoverride import DimStyleOverride
from ezdxf.explode import explode_entity
import logging

if TYPE_CHECKING:
    from ezdxf.eztypes import TagWriter, DimStyle, DXFNamespace, BlockLayout, OCS, BaseLayout, EntityQuery, Drawing

logger = logging.getLogger('ezdxf')

__all__ = ['Dimension', 'OverrideMixin']

acdb_dimension = DefSubclass('AcDbDimension', {
    'version': DXFAttr(280, default=0, dxfversion=DXF2010),  # Version number: 0 = 2010
    'geometry': DXFAttr(2),  # Name of the block that contains the entities that make up the dimension picture
    'dimstyle': DXFAttr(3, default='Standard'),  # dimension style name
    # The dimension style is stored in doc.sections.tables.dimstyles,
    # shortcut Drawings.dimstyles property
    'defpoint': DXFAttr(10, xtype=XType.point3d, default=Vector(0, 0, 0)),
    # definition point for all dimension types in WCS
    'text_midpoint': DXFAttr(11, xtype=XType.point3d),  # midpoint of dimension text in OCS

    # Insertion point for clones of a  dimension—Baseline and Continue (in OCS)
    # located in AcDbDimension? Another error in the DXF reference?
    'insert': DXFAttr(12, xtype=XType.point3d, default=Vector(0, 0, 0), optional=True),

    'dimtype': DXFAttr(70, default=0),  # Dimension type:
    # Values 0–6 are integer values that represent the dimension type.
    # Values 32, 64, and 128 are bit values, which are added to the integer values
コード例 #8
0
from ezdxf.entities import factory
from ezdxf.audit import AuditError

if TYPE_CHECKING:
    from ezdxf.eztypes import (
        TagWriter, Vertex, FaceType, DXFNamespace, DXFEntity, Drawing,
        Line, Arc, Face3d, BaseLayout, Auditor,
    )

__all__ = ['Polyline', 'Polyface', 'Polymesh']

acdb_polyline = DefSubclass('AcDbPolylineDummy', {  # AcDbPolylineDummy is a temp solution while importing
    # 66: obsolete - not read and not written, because POLYLINE without vertices makes no sense
    # a “dummy” point; the X and Y values are always 0, and the Z value is the polyline's elevation
    # (in OCS when 2D, WCS when 3D) x, y ALWAYS 0
    'elevation': DXFAttr(10, xtype=XType.point3d, default=NULLVEC),
    # Polyline flag (bit-coded):
    'flags': DXFAttr(70, default=0),
    # 1 = This is a closed polyline (or a polygon mesh closed in the M direction)
    # 2 = Curve-fit vertices have been added
    # 4 = Spline-fit vertices have been added
    # 8 = This is a 3D polyline
    # 16 = This is a 3D polygon mesh
    # 32 = The polygon mesh is closed in the N direction
    # 64 = The polyline is a polyface mesh
    # 128 = The linetype pattern is generated continuously around the vertices of this polyline
    'default_start_width': DXFAttr(40, default=0, optional=True),
    'default_end_width': DXFAttr(41, default=0, optional=True),
    'm_count': DXFAttr(71, default=0, optional=True),
    'n_count': DXFAttr(72, default=0, optional=True),
    'm_smooth_density': DXFAttr(73, default=0, optional=True),
コード例 #9
0
ファイル: underlay.py プロジェクト: Rahulghuge94/ezdxf
    "PdfUnderlay",
    "DwfUnderlay",
    "DgnUnderlay",
    "PdfDefinition",
    "DgnDefinition",
    "DwfDefinition",
    "Underlay",
    "UnderlayDefinition",
]

acdb_underlay = DefSubclass(
    "AcDbUnderlayReference",
    {
        # Hard reference to underlay definition object
        "underlay_def_handle":
        DXFAttr(340),
        "insert":
        DXFAttr(10, xtype=XType.point3d, default=NULLVEC),
        # Scale x factor:
        "scale_x":
        DXFAttr(
            41,
            default=1,
            validator=validator.is_not_zero,
            fixer=RETURN_DEFAULT,
        ),
        # Scale y factor:
        "scale_y":
        DXFAttr(
            42,
            default=1,
コード例 #10
0
ファイル: shape.py プロジェクト: k3rn3l3rr0r/ezdxf
from ezdxf.lldxf.attributes import DXFAttr, DXFAttributes, DefSubclass, XType
from ezdxf.lldxf.const import DXF12, SUBCLASS_MARKER
from .dxfentity import base_class, SubclassProcessor
from .dxfgfx import DXFGraphic, acdb_entity
from .factory import register_entity

if TYPE_CHECKING:
    from ezdxf.eztypes import TagWriter, DXFNamespace, UCS

__all__ = ['Shape']

acdb_shape = DefSubclass(
    'AcDbShape',
    {
        'thickness':
        DXFAttr(39, default=0, optional=True),  # Thickness
        'insert':
        DXFAttr(10, xtype=XType.point3d, default=Vector(
            0, 0, 0)),  # Insertion point (in WCS)
        'size':
        DXFAttr(40, default=1),
        'name':
        DXFAttr(2, default=''),  # Shape name
        'rotation':
        DXFAttr(50, default=0, optional=True),  # Rotation angle in degrees
        'xscale':
        DXFAttr(41, default=1, optional=True),  # Relative X scale factor
        'oblique':
        DXFAttr(51, default=0, optional=True),  # Oblique angle
        'extrusion':
        DXFAttr(
コード例 #11
0
if TYPE_CHECKING:
    from ezdxf.eztypes import TagWriter, DXFNamespace, Vertex

__all__ = ['Spline']

acdb_spline = DefSubclass(
    'AcDbSpline',
    {
        # Spline flags:
        # 1 = Closed spline
        # 2 = Periodic spline
        # 4 = Rational spline
        # 8 = Planar
        # 16 = Linear (planar bit is also set)
        'flags':
        DXFAttr(70, default=0),
        'degree':
        DXFAttr(71, default=3),
        'n_knots':
        DXFAttr(72, xtype=XType.callback, getter='knot_count'),
        'n_control_points':
        DXFAttr(73, xtype=XType.callback, getter='control_point_count'),
        'n_fit_points':
        DXFAttr(74, xtype=XType.callback, getter='fit_point_count'),
        'knot_tolerance':
        DXFAttr(42, default=1e-10, optional=True),
        'control_point_tolerance':
        DXFAttr(43, default=1e-10, optional=True),
        'fit_tolerance':
        DXFAttr(44, default=1e-10, optional=True),
        # Start- and end tangents should be normalized, but CAD applications do not
コード例 #12
0
ファイル: circle.py プロジェクト: k3rn3l3rr0r/ezdxf
from ezdxf.math import Vector, UCS, OCS, Z_AXIS
from ezdxf.lldxf.attributes import DXFAttr, DXFAttributes, DefSubclass, XType
from ezdxf.lldxf.const import DXF12, SUBCLASS_MARKER
from .dxfentity import base_class, SubclassProcessor
from .dxfgfx import DXFGraphic, acdb_entity
from .factory import register_entity

if TYPE_CHECKING:
    from ezdxf.eztypes import TagWriter, DXFNamespace

__all__ = ['Circle']

acdb_circle = DefSubclass(
    'AcDbCircle', {
        'center':
        DXFAttr(10, xtype=XType.point3d, default=Vector(0, 0, 0)),
        'radius':
        DXFAttr(40, default=1),
        'thickness':
        DXFAttr(39, default=0, optional=True),
        'extrusion':
        DXFAttr(210, xtype=XType.point3d, default=(0, 0, 1), optional=True),
    })


@register_entity
class Circle(DXFGraphic):
    """ DXF CIRCLE entity """
    DXFTYPE = 'CIRCLE'
    DXFATTRIBS = DXFAttributes(base_class, acdb_entity, acdb_circle)
コード例 #13
0
ファイル: dxfclass.py プロジェクト: vshu3000/ezdxf
from typing import TYPE_CHECKING, Tuple
from .dxfentity import DXFEntity, SubclassProcessor, DXFNamespace
from ezdxf.lldxf.attributes import DXFAttr, DXFAttributes, DefSubclass
from ezdxf.lldxf.const import DXF2004, DXF2000
from .factory import register_entity

if TYPE_CHECKING:
    from ezdxf.eztypes import Drawing, ExtendedTags, TagWriter

__all__ = ['DXFClass']

class_def = DefSubclass(
    None,
    {
        # Class DXF record name; always unique
        'name': DXFAttr(1),
        # C++ class name. Used to bind with software that defines object class behavior; always unique
        'cpp_class_name': DXFAttr(2),
        # Application name. Posted in Alert box when a class definition listed in this section is not currently loaded
        'app_name': DXFAttr(3),
        # Proxy capabilities flag. Bit-coded value that indicates the capabilities of this object as a proxy:
        # 0 = No operations allowed (0)
        # 1 = Erase allowed (0x1)
        # 2 = Transform allowed (0x2)
        # 4 = Color change allowed (0x4)
        # 8 = Layer change allowed (0x8)
        # 16 = Linetype change allowed (0x10)
        # 32 = Linetype scale change allowed (0x20)
        # 64 = Visibility change allowed (0x40)
        # 128 = Cloning allowed (0x80)
        # 256 = Lineweight change allowed (0x100)
コード例 #14
0
from typing import TYPE_CHECKING, Iterable, cast, Tuple, Union, Optional, List
from ezdxf.math import Vector, UCS
from ezdxf.lldxf.attributes import DXFAttr, DXFAttributes, DefSubclass, XType
from ezdxf.lldxf.const import DXF12, SUBCLASS_MARKER, DXFValueError, DXFKeyError
from .dxfentity import base_class, SubclassProcessor
from .dxfgfx import DXFGraphic, acdb_entity, SeqEnd
from .factory import register_entity

if TYPE_CHECKING:
    from ezdxf.eztypes import TagWriter, Vertex, DXFNamespace, DXFEntity, Drawing, Attrib, AttDef, UCS

__all__ = ['Insert']

# multiple insert has subclass id AcDbMInsertBlock
acdb_block_reference = DefSubclass('AcDbBlockReference', {
    'attribs_follow': DXFAttr(66, default=0, optional=True),
    'name': DXFAttr(2),
    'insert': DXFAttr(10, xtype=XType.any_point),
    'xscale': DXFAttr(41, default=1, optional=True),
    'yscale': DXFAttr(42, default=1, optional=True),
    'zscale': DXFAttr(43, default=1, optional=True),
    'rotation': DXFAttr(50, default=0, optional=True),
    'column_count': DXFAttr(70, default=1, optional=True),
    'row_count': DXFAttr(71, default=1, optional=True),
    'column_spacing': DXFAttr(44, default=0, optional=True),
    'row_spacing': DXFAttr(45, default=0, optional=True),
    'extrusion': DXFAttr(210, xtype=XType.point3d, default=Vector(0, 0, 1), optional=True),
})


@register_entity
コード例 #15
0
from ezdxf.tools import set_flag_state
from .dxfentity import base_class, SubclassProcessor
from .dxfgfx import acdb_entity, DXFGraphic
from .text import Text, acdb_text
from .factory import register_entity

if TYPE_CHECKING:
    from ezdxf.eztypes import TagWriter, Tags, Drawing, DXFNamespace, DXFEntity

__all__ = ['AttDef', 'Attrib']

acdb_attdef = DefSubclass(
    'AcDbAttributeDefinition',
    {
        'version':
        DXFAttr(280, default=0,
                dxfversion=DXF2010),  # Version number: 0 = 2010
        'prompt':
        DXFAttr(3, default=''),  # Prompt string
        'tag':
        DXFAttr(2, default=''),  # Tag string (cannot contain spaces)
        'flags':
        DXFAttr(70, default=0),
        # 1 = Attribute is invisible (does not appear)
        # 2 = This is a constant attribute
        # 4 = Verification is required on input of this attribute
        # 8 = Attribute is preset (no prompt during insertion)
        'field_length':
        DXFAttr(73, default=0,
                optional=True),  # Field length (optional) (not currently used)
        'valign':
        DXFAttr(74, default=0, optional=True),
コード例 #16
0
from ezdxf.math import NULLVEC, X_AXIS, Z_AXIS
from .spline import Spline, acdb_spline
from .dxfentity import base_class, SubclassProcessor
from .dxfgfx import acdb_entity
from .factory import register_entity

if TYPE_CHECKING:
    from ezdxf.eztypes import TagWriter, DXFNamespace, Matrix44

__all__ = ['Helix']

acdb_helix = DefSubclass(
    'AcDbHelix',
    {
        'major_release_number':
        DXFAttr(90, default=29),
        'maintenance_release_number':
        DXFAttr(91, default=63),
        'axis_base_point':
        DXFAttr(10, xtype=XType.point3d, default=NULLVEC),
        'start_point':
        DXFAttr(
            11,
            xtype=XType.point3d,
            default=X_AXIS,
            validator=validator.is_not_null_vector,
            fixer=RETURN_DEFAULT,
        ),
        'axis_vector':
        DXFAttr(
            12,
コード例 #17
0
from ezdxf.lldxf.attributes import DXFAttr, DXFAttributes, DefSubclass, XType
from ezdxf.lldxf.const import SUBCLASS_MARKER, DXF2000
from .dxfentity import base_class, SubclassProcessor
from .dxfgfx import DXFGraphic, acdb_entity
from .factory import register_entity

if TYPE_CHECKING:
    from ezdxf.eztypes import TagWriter, DXFNamespace, UCS

__all__ = ['Ellipse']

acdb_ellipse = DefSubclass(
    'AcDbEllipse',
    {
        'center':
        DXFAttr(10, xtype=XType.point3d, default=Vector(0, 0, 0)),
        'major_axis':
        DXFAttr(11, xtype=XType.point3d, default=Vector(
            1, 0, 0)),  # relative to the center
        # extrusion does not establish an OCS, it is just the normal vector of the ellipse plane.
        'extrusion':
        DXFAttr(210, xtype=XType.point3d, default=(0, 0, 1), optional=True),
        'ratio':
        DXFAttr(40, default=1),  # has to be in range 1e-6 to 1
        'start_param':
        DXFAttr(41, default=0),  # this value is 0.0 for a full ellipse
        'end_param':
        DXFAttr(42,
                default=math.pi * 2),  # this value is 2*pi for a full ellipse
    })
コード例 #18
0
if TYPE_CHECKING:
    from ezdxf.eztypes import TagWriter, Drawing, DXFNamespace, Auditor

__all__ = ['Dictionary', 'DictionaryWithDefault', 'DictionaryVar']

acdb_dictionary = DefSubclass(
    'AcDbDictionary',
    {
        # If set to 1, indicates that elements of the dictionary are to be treated
        # as hard-owned:
        'hard_owned':
        DXFAttr(
            280,
            default=0,
            optional=True,
            validator=validator.is_integer_bool,
            fixer=RETURN_DEFAULT,
        ),

        # Duplicate record cloning flag (determines how to merge duplicate entries):
        # 0 = not applicable
        # 1 = keep existing
        # 2 = use clone
        # 3 = <xref>$0$<name>
        # 4 = $0$<name>
        # 5 = Unmangle name
        'cloning':
        DXFAttr(
            281,
            default=1,
コード例 #19
0
        TagWriter,
        Vertex,
        DXFNamespace,
        AttDef,
        BlockLayout,
        BaseLayout,
        Auditor,
    )

__all__ = ['Insert']

# Multi-INSERT has subclass id AcDbMInsertBlock
acdb_block_reference = DefSubclass(
    'AcDbBlockReference', {
        'attribs_follow':
        DXFAttr(66, default=0, optional=True),
        'name':
        DXFAttr(2, validator=validator.is_valid_block_name),
        'insert':
        DXFAttr(10, xtype=XType.any_point),
        'xscale':
        DXFAttr(
            41,
            default=1,
            optional=True,
            validator=validator.is_not_zero,
            fixer=RETURN_DEFAULT,
        ),
        'yscale':
        DXFAttr(
            42,
コード例 #20
0
        EntityQuery,
    )

logger = logging.getLogger('ezdxf')
ADSK_CONSTRAINTS = "*ADSK_CONSTRAINTS"

__all__ = [
    'Dimension', 'ArcDimension', 'RadialDimensionLarge', 'OverrideMixin'
]

acdb_dimension = DefSubclass(
    'AcDbDimension',
    {
        # Version number: 0 = 2010
        'version':
        DXFAttr(280, default=0, dxfversion=DXF2010),

        # Name of the block that contains the entities that make up the dimension
        # picture
        # Important: DIMENSION constraints do no have this group code 2:
        'geometry':
        DXFAttr(2, validator=validator.is_valid_block_name),

        # Dimension style name:
        'dimstyle':
        DXFAttr(
            3,
            default='Standard',
            validator=validator.is_valid_table_name,
            # Do not fix automatically, but audit fixes value as 'Standard'
        ),
コード例 #21
0
ファイル: shape.py プロジェクト: tbwhsb88/ezdxf
from ezdxf.math.transformtools import OCSTransform
from .dxfentity import base_class, SubclassProcessor
from .dxfgfx import DXFGraphic, acdb_entity
from .factory import register_entity

if TYPE_CHECKING:
    from ezdxf.eztypes import TagWriter, DXFNamespace, Matrix44

__all__ = ['Shape']

acdb_shape = DefSubclass(
    'AcDbShape',
    {
        # Thickness could be negative:
        'thickness':
        DXFAttr(39, default=0, optional=True),

        # Insertion point (in WCS)
        'insert':
        DXFAttr(10, xtype=XType.point3d, default=NULLVEC),

        # Shape size:
        'size':
        DXFAttr(40, default=1),

        # Shape name:
        'name':
        DXFAttr(2, default=''),

        # Rotation angle in degrees:
        'rotation':
コード例 #22
0
            vertices.append(vertices[0])
        return vertices

    def destroy(self) -> None:
        if not self.is_alive:
            return

        del self._boundary_path
        super().destroy()


acdb_image = DefSubclass(
    'AcDbRasterImage',
    {
        'class_version':
        DXFAttr(90, dxfversion=DXF2000, default=0),
        'insert':
        DXFAttr(10, xtype=XType.point3d),

        # U-vector of a single pixel (points along the visual bottom of the image,
        # starting at the insertion point)
        'u_pixel':
        DXFAttr(11, xtype=XType.point3d),

        # V-vector of a single pixel (points along the visual left side of the
        # image, starting at the insertion point)
        'v_pixel':
        DXFAttr(12, xtype=XType.point3d),

        # Image size in pixels
        'image_size':
コード例 #23
0
from ezdxf.math.transformtools import OCSTransform
from .dxfentity import base_class, SubclassProcessor
from .dxfgfx import DXFGraphic, acdb_entity, elevation_to_z_axis
from .factory import register_entity

if TYPE_CHECKING:
    from ezdxf.eztypes import TagWriter, DXFNamespace

__all__ = ['Solid', 'Trace', 'Face3d']

acdb_trace = DefSubclass(
    'AcDbTrace',
    {
        # 1. corner Solid WCS; Trace OCS
        'vtx0':
        DXFAttr(10, xtype=XType.point3d, default=NULLVEC),

        # 2. corner Solid WCS; Trace OCS
        'vtx1':
        DXFAttr(11, xtype=XType.point3d, default=NULLVEC),

        # 3. corner Solid WCS; Trace OCS
        'vtx2':
        DXFAttr(12, xtype=XType.point3d, default=NULLVEC),

        # 4. corner Solid WCS; Trace OCS:
        # If only three corners are entered to define the SOLID, then the fourth
        # corner coordinate is the same as the third.
        'vtx3':
        DXFAttr(13, xtype=XType.point3d, default=NULLVEC),
コード例 #24
0
ファイル: dxfentity.py プロジェクト: ericgcc/ezdxf
from .appdata import AppData, Reactors
from .dxfns import DXFNamespace, SubclassProcessor
from .xdata import XData, EmbeddedObjects
from .xdict import ExtensionDict

logger = logging.getLogger('ezdxf')

if TYPE_CHECKING:
    from ezdxf.eztypes import Auditor, TagWriter, Drawing, DXFAttr

__all__ = ['DXFEntity', 'DXFTagStorage', 'base_class']

base_class = DefSubclass(
    None,
    {
        'handle': DXFAttr(5),

        # owner: Soft-pointer ID/handle to owner BLOCK_RECORD object
        # This tag is not supported by DXF R12, but is used intern to unify entity
        # handling between DXF R12 and DXF R2000+
        # Do not write this tag into DXF R12 files!
        'owner': DXFAttr(330),

        # Application defined data can only appear here:
        # 102, {APPID ... multiple entries possible DXF R12?
        # 102, {ACAD_REACTORS ... one entry DXF R2000+, optional
        # 102, {ACAD_XDICTIONARY  ... one entry DXF R2000+, optional
    })

T = TypeVar('T', bound='DXFEntity')
コード例 #25
0
ファイル: dxfgfx.py プロジェクト: Constructionware/ezdxf
    'layer',
    'linetype',
    'color',
    'lineweight',
    'ltscale',
    'true_color',
    'color_name',
    'transparency',
}

acdb_entity = DefSubclass(
    'AcDbEntity',
    {
        # Layer name as string, no auto fix for invalid names!
        'layer':
        DXFAttr(8, default='0', validator=validator.is_valid_layer_name),

        # Linetype name as string, no auto fix for invalid names!
        'linetype':
        DXFAttr(
            6,
            default='BYLAYER',
            optional=True,
            validator=validator.is_valid_table_name,
        ),
        # ACI color index, BYBLOCK=0, BYLAYER=256, BYOBJECT=257:
        'color':
        DXFAttr(
            62,
            default=256,
            optional=True,
コード例 #26
0
from .dxfgfx import DXFGraphic, acdb_entity
from .objectcollection import ObjectCollection
from ezdxf.entities.factory import register_entity

if TYPE_CHECKING:
    from ezdxf.eztypes import TagWriter, Drawing, DXFNamespace

__all__ = ['MLine', 'MLineStyle', 'MLineStyleCollection']

# Usage example: CADKitSamples\Lock-Off.dxf

acdb_mline = DefSubclass(
    'AcDbMline',
    OrderedDict({
        'mline_style_name':
        DXFAttr(2, default='Standard'),
        'mline_style_handle':
        DXFAttr(340, default=0),
        'scale_factor':
        DXFAttr(40, default=1),

        # Justification
        # 0 = Top
        # 1 = Zero
        # 2 = Bottom
        'justification':
        DXFAttr(70, default=0),

        # Flags (bit-coded values):
        # 1 = Has at least one vertex (code 72 is greater than 0)
        # 2 = Closed
コード例 #27
0
class DXFGroup(DXFEntity):
    __slots__ = ()
    # groups are not allowed in block definitions
    TEMPLATE = ExtendedTags.from_text(_GROUP_TPL)
    DXFATTRIBS = DXFAttributes(
        none_subclass,
        DefSubclass(
            'AcDbGroup', {
                'description': DXFAttr(300),
                'unnamed': DXFAttr(70),
                'selectable': DXFAttr(71),
            }),
    )

    @property
    def AcDbGroup(self):
        return self.tags.subclasses[1]

    def __iter__(self):
        """ Yields all DXF entities of this group as wrapped DXFEntity (LINE, CIRCLE, ...) objects.
        """
        wrap = self.dxffactory.wrap_handle
        for handle in self.handles():
            try:
                entity = wrap(handle)
                yield entity
            except KeyError:  # handle not in entity database, maybe entity were deleted; internal exception
                pass

    def __len__(self):
        return sum(1 for tag in self.AcDbGroup if tag.code == GROUP_ITEM_CODE)

    def __contains__(self, item):
        handle = item if isstring(item) else item.dxf.handle
        return handle in set(self.handles())

    def handles(self):
        return (tag.value for tag in self.AcDbGroup
                if tag.code == GROUP_ITEM_CODE)

    def get_name(self):
        group_table = self.dxffactory.wrap_handle(
            self.dxf.owner
        )  # returns DXFDictionary() and not GroupManager()!!!
        my_handle = self.dxf.handle
        for name, handle in group_table.items():
            if handle == my_handle:
                return name
        return None

    @contextmanager
    def edit_data(self):
        data = list(self)
        yield data
        self.set_data(data)

    def set_data(self, entities):
        entities = list(entities)  # for generators
        if not all_entities_on_same_layout(entities):
            raise DXFValueError(
                "All entities have to be on the same layout (model space or any paper layout but not block)."
            )
        self.clear()
        self.AcDbGroup.extend(
            DXFTag(GROUP_ITEM_CODE, entity.dxf.handle) for entity in entities)

    def extend(self, entities):
        with self.edit_data() as e:
            e.extend(entities)

    def clear(self):
        """ Remove all entity references, does not delete any drawing entities referenced by this group.
        """
        self.AcDbGroup.remove_tags((GROUP_ITEM_CODE, ))

    def remove_invalid_handles(self):
        """ Remove invalid handles from group.

        Invalid handles: deleted entities, entities in a block layout
        """
        def handle_not_in_block_definition(handle):
            wrap = self.dxffactory.wrap_handle  # shortcut
            # owner block_record.layout is 0 if entity is in a block definition
            owner_handle = wrap(handle).dxf.owner
            return wrap(owner_handle).dxf.layout != 0

        db = self.entitydb  # faster local var
        valid_handles = [handle for handle in self.handles() if handle in db]
        self.clear()

        # If one entity is in a block layout remove all entities, because they have to be on the same layout
        if len(valid_handles) and handle_not_in_block_definition(
                valid_handles[0]):
            self.AcDbGroup.extend(
                DXFTag(GROUP_ITEM_CODE, handle) for handle in valid_handles)
コード例 #28
0
from .dxfgfx import DXFGraphic, acdb_entity
from .factory import register_entity

if TYPE_CHECKING:
    from ezdxf.eztypes import TagWriter, DXFNamespace, Drawing, Vertex, Tags, UCS

__all__ = ['Spline']

acdb_spline = DefSubclass('AcDbSpline', {
    # Spline flag (bit coded):
    # 1 = Closed spline
    # 2 = Periodic spline
    # 4 = Rational spline
    # 8 = Planar
    # 16 = Linear (planar bit is also set)
    'flags': DXFAttr(70, default=0),
    'degree': DXFAttr(71, default=3),
    'n_knots': DXFAttr(72, xtype=XType.callback, getter='knot_count'),
    'n_control_points': DXFAttr(73, xtype=XType.callback, getter='control_point_count'),
    'n_fit_points': DXFAttr(74, xtype=XType.callback, getter='fit_point_count'),
    'knot_tolerance': DXFAttr(42, default=1e-10, optional=True),
    'control_point_tolerance': DXFAttr(43, default=1e-10, optional=True),
    'fit_tolerance': DXFAttr(44, default=1e-10, optional=True),
    'start_tangent': DXFAttr(12, xtype=XType.point3d, optional=True),
    'end_tangent': DXFAttr(13, xtype=XType.point3d, optional=True),
    # extrusion is the normal vector (omitted if the spline is non-planar)
    'extrusion': DXFAttr(210, xtype=XType.point3d, default=Vector(0, 0, 1), optional=True),
    # 10: Control points (in WCS); one entry per control point
    # 11: Fit points (in WCS); one entry per fit point
    # 40: Knot value (one entry per knot)
    # 41: Weight (if not 1); with multiple group pairs, they are present if all are not 1
コード例 #29
0
ファイル: blockrecord.py プロジェクト: ericgcc/ezdxf
from ezdxf.entities.layer import acdb_symbol_table_record

from .factory import register_entity

logger = logging.getLogger('ezdxf')

if TYPE_CHECKING:
    from ezdxf.eztypes import (
        TagWriter, DXFNamespace, Block, EndBlk, DXFGraphic,
        EntitySpace, BlockLayout,
    )

__all__ = ['BlockRecord']

acdb_blockrec = DefSubclass('AcDbBlockTableRecord', {
    'name': DXFAttr(2, validator=validator.is_valid_block_name),
    # handle to associated DXF LAYOUT object
    'layout': DXFAttr(340, default='0'),
    # 0 = can not explode; 1 = can explode
    'explode': DXFAttr(280, default=1, dxfversion=DXF2007,
                       validator=validator.is_integer_bool,
                       fixer=RETURN_DEFAULT
                       ),
    # 0 = scale non uniformly; 1 = scale uniformly
    'scale': DXFAttr(281, default=0, dxfversion=DXF2007,
                     validator=validator.is_integer_bool,
                     fixer=RETURN_DEFAULT,
                     ),
    # see ezdxf/units.py
    'units': DXFAttr(70, default=0, dxfversion=DXF2007,
                     validator=validator.is_in_integer_range(0, 25),
コード例 #30
0
ファイル: dxfgroups.py プロジェクト: yanbin-ha/ezdxf
from .dxfobj import DXFObject
from .factory import register_entity
from .objectcollection import ObjectCollection

logger = logging.getLogger('ezdxf')

if TYPE_CHECKING:
    from ezdxf.eztypes import (
        TagWriter, Drawing, DXFNamespace, Auditor, EntityDB,
    )

__all__ = ['DXFGroup', 'GroupCollection']

acdb_group = DefSubclass('AcDbGroup', {
    # Group description
    'description': DXFAttr(300, default=''),

    # 1 = Unnamed
    # 0 = Named
    'unnamed': DXFAttr(
        70, default=1, validator=validator.is_integer_bool,
        fixer=RETURN_DEFAULT,
    ),

    # 1 = Selectable
    # 0 = Not selectable
    'selectable': DXFAttr(
        71, default=1,
        validator=validator.is_integer_bool,
        fixer=RETURN_DEFAULT,
    ),