Example #1
0
__all__ = [
    "Body",
    "Solid3d",
    "Region",
    "Surface",
    "ExtrudedSurface",
    "LoftedSurface",
    "RevolvedSurface",
    "SweptSurface",
]

acdb_modeler_geometry = DefSubclass(
    "AcDbModelerGeometry",
    {
        "version": DXFAttr(70, default=1),
        "flags": DXFAttr(290, dxfversion=DXF2013),
        "uid": DXFAttr(2, dxfversion=DXF2013),
    },
)
acdb_modeler_geometry_group_codes = group_code_mapping(acdb_modeler_geometry)

# with R2013/AC1027 Modeler Geometry of ACIS data is stored in the ACDSDATA
# section as binary encoded information detection:
# group code 70, 1, 3 is missing
# group code 290, 2 present
#
#   0
# ACDSRECORD
#  90
# 1
#   2
Example #2
0
20
0.0
"""

# removed tag (code=47, 0.0442352806926743) from Template: pixel size - caused problems in AutoCAD

# default is a solid fil hatch
hatch_subclass = DefSubclass(
    'AcDbHatch',
    {
        'elevation': DXFAttr(10, xtype=XType.point3d, default=(0.0, 0.0, 0.0)),
        'extrusion': DXFAttr(210, xtype=XType.point3d,
                             default=(0.0, 0.0, 1.0)),
        'pattern_name': DXFAttr(2, default='SOLID'),  # for solid fill
        'solid_fill': DXFAttr(70, default=1),  # pattern fill = 0
        'associative': DXFAttr(71, default=0),  # associative flag = 0
        'hatch_style': DXFAttr(75, default=const.HATCH_STYLE_OUTERMOST
                               ),  # 0=normal; 1=outer; 2=ignore
        'pattern_type': DXFAttr(76, default=const.HATCH_TYPE_PREDEFINED
                                ),  # 0=user; 1=predefined; 2=custom???
        'pattern_angle': DXFAttr(52, default=0.0),  # degrees (360deg = circle)
        'pattern_scale': DXFAttr(41, default=1.0),
        'pattern_double': DXFAttr(77, default=0),  # 0=not double; 1= double
        'n_seed_points': DXFAttr(98),  # number of seed points
    })

GRADIENT_CODES = frozenset(
    [450, 451, 452, 453, 460, 461, 462, 463, 470, 421, 63])
PATH_CODES = frozenset([
    10, 11, 12, 13, 40, 42, 50, 51, 42, 72, 73, 74, 92, 93, 94, 95, 96, 97, 330
])
PATTERN_DEFINITION_LINE_CODES = frozenset((53, 43, 44, 45, 46, 79, 49))
Example #3
0
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,
            validator=validator.is_in_integer_range(0, 6),
            fixer=RETURN_DEFAULT,
        ),
        # 3: entry name
        # 350: entry handle, some DICTIONARY objects have 360 as handle group code,
        # this is accepted by AutoCAD but not documented by the DXF reference!
        # ezdxf replaces group code 360 by 350.
    })
Example #4
0
acdb_visualstyle = DefSubclass(
    'AcDbVisualStyle',
    {
        'description': DXFAttr(2),
        'style_type': DXFAttr(70),
        # 0 = Flat
        # 1 = FlatWithEdges
        # 2 = Gouraud
        # 3 = GouraudWithEdges
        # 4 = 2dWireframe
        # 5 = Wireframe
        # 6 = Hidden
        # 7 = Basic
        # 8 = Realistic
        # 9 = Conceptual
        # 10 = Modeling
        # 11 = Dim
        # 12 = Brighten
        # 13 = Thicken
        # 14 = Linepattern
        # 15 = Facepattern
        # 16 = ColorChange
        # 20 = JitterOff
        # 21 = OverhangOff
        # 22 = EdgeColorOff
        # 23 = Shades of Gray
        # 24 = Sketchy
        # 25 = X-Ray
        # 26 = Shaded with edges
        # 27 = Shaded
        'face_lighting_model': DXFAttr(71),
        # 0 = Invisible
        # 1 = Visible
        # 2 = Phong
        # 3 = Gooch
        'face_lighting_quality': DXFAttr(72),
        # 0 = No lighting
        # 1 = Per face lighting
        # 2 = Per vertex lighting
        'face_color_mode': DXFAttr(73),
        # 0 = No color
        # 1 = Object color
        # 2 = Background color
        # 3 = Custom color
        # 4 = Mono color
        # 5 = Tinted
        # 6 = Desaturated
        'face_modifiers': DXFAttr(90),
        # 0 = No modifiers
        # 1 = Opacity
        # 2 = Specular
        'face_opacity_level': DXFAttr(40),
        'face_specular_level': DXFAttr(41),
        'color1': DXFAttr(62),
        'color2': DXFAttr(63),
        'face_style_mono_color': DXFAttr(421),
        'edge_style_model': DXFAttr(74),
        # 0 = No edges
        # 1 = Isolines
        # 2 = Facet edges
        'edge_style': DXFAttr(91),
        'edge_intersection_color': DXFAttr(64),
        'edge_obscured_color': DXFAttr(65),
        'edge_obscured_linetype': DXFAttr(75),
        'edge_intersection_linetype': DXFAttr(175),
        'edge_crease_angle': DXFAttr(42),
        'edge_modifiers': DXFAttr(92),
        'edge_color': DXFAttr(66),
        'edge_opacity_level': DXFAttr(43),
        'edge_width': DXFAttr(76),
        'edge_overhang': DXFAttr(77),
        'edge_jitter': DXFAttr(78),
        'edge_silhouette_color': DXFAttr(67),
        'edge_silhouette_width': DXFAttr(79),
        'edge_halo_gap': DXFAttr(170),
        'edge_isoline_count': DXFAttr(171),
        'edge_hide_precision': DXFAttr(290),  # flag
        'edge_style_apply': DXFAttr(174),  # flag
        'style_display_settings': DXFAttr(93),
        'brightness': DXFAttr(44),
        'shadow_type': DXFAttr(173),
        'unknown1': DXFAttr(177),  # required if xdata is present?
        'internal_use_only_flag':
        DXFAttr(291),  # visual style only use internal
        # Xdata must follow tag 291 (AutoCAD -> 'Xdata wasn't read' error)
        # 70: Xdata count (count of tag groups)
        # any code, value: multiple tags build a tag group
        # 176, 1: end of group marker
        # e.g. (291, 0) (70, 2) (62, 7) (420, 16777215) (176, 1) (90, 1) (176, 1)
    })
Example #5
0
# Created 2019-02-15
from typing import TYPE_CHECKING
from ezdxf.lldxf.attributes import DXFAttr, DXFAttributes, DefSubclass
from ezdxf.lldxf.const import DXF12, SUBCLASS_MARKER
from .dxfentity import base_class, SubclassProcessor
from .dxfgfx import acdb_entity
from .circle import acdb_circle, Circle
from .factory import register_entity

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

__all__ = ['Arc']

acdb_arc = DefSubclass('AcDbArc', {
    'start_angle': DXFAttr(50, default=0),
    'end_angle': DXFAttr(51, default=360),
})


@register_entity
class Arc(Circle):
    """ DXF ARC entity """
    DXFTYPE = 'ARC'
    DXFATTRIBS = DXFAttributes(base_class, acdb_entity, acdb_circle, acdb_arc)

    def load_dxf_attribs(self,
                         processor: SubclassProcessor = None
                         ) -> 'DXFNamespace':
        dxf = super().load_dxf_attribs(processor)
        if processor:
            tags = processor.load_dxfattribs_into_namespace(dxf, acdb_arc)
Example #6
0
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:
        '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'
        ),

        # definition point for all dimension types in WCS:
        'defpoint':
        DXFAttr(10, xtype=XType.point3d, default=NULLVEC),

        # Midpoint of dimension text in OCS:
        'text_midpoint':
        DXFAttr(11, xtype=XType.point3d),

        # 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=NULLVEC, optional=True),

        # 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 (value 32 is always set in R13 and later releases)
        # 0 = Rotated, horizontal, or vertical;
        # 1 = Aligned
        # 2 = Angular;
        # 3 = Diameter;
        # 4 = Radius
        # 5 = Angular 3 point;
        # 6 = Ordinate
        # 8 = Arc Dimension -> ARC_DIMENSION
        # 32 = Indicates that the block reference (group code 2) is referenced by
        # this dimension only
        # 64 = Ordinate type. This is a bit value (bit 7) used only with integer
        #   value 6. If set, ordinate is X-type; if not set, ordinate is Y-type
        # 128 = This is a bit value (bit 8) added to the other group 70 values if
        #   the dimension text has been positioned at a user-defined location
        #   rather than at the default location.
        'dimtype':
        DXFAttr(70, default=0),

        # Attachment point:
        # 1 = Top left
        # 2 = Top center
        # 3 = Top right
        # 4 = Middle left
        # 5 = Middle center
        # 6 = Middle right
        # 7 = Bottom left
        # 8 = Bottom center
        # 9 = Bottom right
        'attachment_point':
        DXFAttr(
            71,
            default=5,
            dxfversion=DXF2000,
            validator=validator.is_in_integer_range(0, 10),
            fixer=RETURN_DEFAULT,
        ),

        # Dimension text line-spacing style
        # 1 (or missing) = At least (taller characters will override)
        # 2 = Exact (taller characters will not override)
        'line_spacing_style':
        DXFAttr(
            72,
            default=1,
            dxfversion=DXF2000,
            optional=True,
            validator=validator.is_in_integer_range(1, 3),
            fixer=RETURN_DEFAULT,
        ),

        # Dimension text-line spacing factor:
        # Percentage of default (3-on-5) line spacing to be applied. Valid values
        # range from 0.25 to 4.00
        'line_spacing_factor':
        DXFAttr(
            41,
            dxfversion=DXF2000,
            optional=True,
            validator=validator.is_in_float_range(0.25, 4.00),
            fixer=validator.fit_into_float_range(0.25, 4.00),
        ),

        # Actual measurement (optional; read-only value)
        'actual_measurement':
        DXFAttr(42, dxfversion=DXF2000, optional=True),
        'unknown1':
        DXFAttr(73, dxfversion=DXF2000, optional=True),
        'flip_arrow_1':
        DXFAttr(
            74,
            dxfversion=DXF2000,
            optional=True,
            validator=validator.is_integer_bool,
            fixer=validator.fix_integer_bool,
        ),
        'flip_arrow_2':
        DXFAttr(
            75,
            dxfversion=DXF2000,
            optional=True,
            validator=validator.is_integer_bool,
            fixer=validator.fix_integer_bool,
        ),

        # Dimension text explicitly entered by the user
        # default is the measurement.
        # If null or “<>”, the dimension measurement is drawn as the text,
        # if “ “ (one blank space), the text is suppressed.
        # Anything else is drawn as the text.
        'text':
        DXFAttr(1, default='', optional=True),

        # Linear dimension types with an oblique angle have an optional group
        # code 52. When added to the rotation angle of the linear dimension (group
        # code 50), it gives the angle of the extension lines
        # DXF reference error: wrong subclass AcDbAlignedDimension
        'oblique_angle':
        DXFAttr(52, default=0, optional=True),

        # The optional group code 53 is the rotation angle of the dimension
        # text away from its default orientation (the direction of the dimension
        # line)
        'text_rotation':
        DXFAttr(53, default=0, optional=True),

        # All dimension types have an optional 51 group code, which
        # indicates the horizontal direction for the dimension entity.
        # The dimension entity determines the orientation of dimension text and
        # lines for horizontal, vertical, and rotated linear dimensions.
        # This group value is the negative of the angle between the OCS X axis and
        # the UCS X axis. It is always in the XY plane of the OCS
        'horizontal_direction':
        DXFAttr(51, default=0, optional=True),
        'extrusion':
        DXFAttr(
            210,
            xtype=XType.point3d,
            default=Z_AXIS,
            optional=True,
            validator=validator.is_not_null_vector,
            fixer=RETURN_DEFAULT,
        ),
    })
Example #7
0
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,
            validator=validator.is_valid_aci_color,
            fixer=RETURN_DEFAULT,
        ),
        # modelspace=0, paperspace=1
        'paperspace':
        DXFAttr(
            67,
            default=0,
            optional=True,
            validator=validator.is_integer_bool,
            fixer=RETURN_DEFAULT,
        ),

        # Lineweight in mm times 100 (e.g. 0.13mm = 13). Smallest line weight is 13
        # and biggest line weight is 200, values outside this range prevents AutoCAD
        # from loading the file.
        # Special values: BYLAYER=-1, BYBLOCK=-2, DEFAULT=-3
        'lineweight':
        DXFAttr(
            370,
            default=-1,
            dxfversion=DXF2000,
            optional=True,
            validator=validator.is_valid_lineweight,
            fixer=validator.fix_lineweight,
        ),
        'ltscale':
        DXFAttr(
            48,
            default=1.0,
            dxfversion=DXF2000,
            optional=True,
            validator=validator.is_positive,
            fixer=RETURN_DEFAULT,
        ),
        # visible=0, invisible=1
        'invisible':
        DXFAttr(60, default=0, dxfversion=DXF2000, optional=True),

        # True color as 0x00RRGGBB 24-bit value
        'true_color':
        DXFAttr(420, dxfversion=DXF2004, optional=True),

        # Color name as string. Color books are stored in .stb config files?
        'color_name':
        DXFAttr(430, dxfversion=DXF2004, optional=True),

        # Transparency value 0x020000TT 0 = fully transparent / 255 = opaque
        'transparency':
        DXFAttr(440, dxfversion=DXF2004, optional=True),

        # Shadow mode:
        # 0 = Casts and receives shadows
        # 1 = Casts shadows
        # 2 = Receives shadows
        # 3 = Ignores shadows
        'shadow_mode':
        DXFAttr(284, dxfversion=DXF2007, optional=True),
        'material_handle':
        DXFAttr(347, dxfversion=DXF2007, optional=True),
        'visualstyle_handle':
        DXFAttr(348, dxfversion=DXF2007, optional=True),

        # PlotStyleName type enum (AcDb::PlotStyleNameType). Stored and moved around
        # as a 16-bit integer. Custom non-entity
        'plotstyle_enum':
        DXFAttr(380, dxfversion=DXF2007, default=1, optional=True),

        # Handle value of the PlotStyleName object, basically a hard pointer, but
        # has a different range to make backward compatibility easier to deal with.
        'plotstyle_handle':
        DXFAttr(390, dxfversion=DXF2007, optional=True),

        # 92 or 160?: Number of bytes in the proxy entity graphics represented in
        # the subsequent 310 groups, which are binary chunk records (optional)
        # 310: Proxy entity graphics data (multiple lines; 256 characters max. per
        # line) (optional), compiled by TagCompiler() to a DXFBinaryTag() objects
    })
Example #8
0
    OWNER_CODE,
    SUBCLASS_MARKER,
    DXFInternalEzdxfError,
)

from .dxfentity import SubclassProcessor, DXFEntity
from .factory import register_entity

if TYPE_CHECKING:
    from ezdxf.eztypes import TagWriter, DXFNamespace

__all__ = ['TableHead']

base_class = DefSubclass(None, {
    'name': DXFAttr(2),
    'handle': DXFAttr(5),
    'owner': DXFAttr(330),
})

acdb_symbol_table = DefSubclass('AcDbSymbolTable', {
    'count': DXFAttr(70, default=0),
})


@register_entity
class TableHead(DXFEntity):
    DXFTYPE = 'TABLE'
    DXFATTRIBS = DXFAttributes(base_class, acdb_symbol_table)

    def load_dxf_attribs(self,
                         processor: SubclassProcessor = None
Example #9
0
from ezdxf.lldxf.const import SUBCLASS_MARKER, DXF2007
from .dxfentity import base_class, SubclassProcessor
from .dxfgfx import DXFGraphic, acdb_entity
from .dxfobj import DXFObject
from .objectcollection import ObjectCollection
from .factory import register_entity

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

__all__ = ['ACADTable']

acdb_block_reference = DefSubclass(
    'AcDbBlockReference',
    {
        'geometry':
        DXFAttr(2),  # Block name; an anonymous block begins with a *T value
        'insert': DXFAttr(10, xtype=XType.point3d, default=Vector(
            0, 0, 0)),  # Insertion point
    })

acdb_table = DefSubclass(
    'AcDbTable',
    {
        'version': DXFAttr(280),  # Table data version number: 0 = 2010
        'table_style_id':
        DXFAttr(342),  # Hard pointer ID of the TABLESTYLE object
        'block_record':
        DXFAttr(343),  # Hard pointer ID of the owning BLOCK record
        'horizontal_direction': DXFAttr(11),  # Horizontal direction vector
        'table_value': DXFAttr(90),  # Flag for table value (unsigned integer)
        'n_rows': DXFAttr(91),  # Number of rows
Example #10
0
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),

    # Elevation is a legacy feature from R11 and prior, do not use this
    # attribute, store the entity elevation in the z-axis of the vertices.
    # ezdxf does not export the elevation attribute!
    'elevation': DXFAttr(38, default=0, optional=True),

    'xscale': DXFAttr(
        41, default=1, optional=True,
        validator=validator.is_not_zero,
        fixer=RETURN_DEFAULT,
    ),
    'yscale': DXFAttr(
        42, default=1, optional=True,
        validator=validator.is_not_zero,
        fixer=RETURN_DEFAULT,
    ),
    'zscale': DXFAttr(
        43, default=1, optional=True,
        validator=validator.is_not_zero,
        fixer=RETURN_DEFAULT,
    ),
    'rotation': DXFAttr(50, default=0, optional=True),
    'column_count': DXFAttr(
        70, default=1, optional=True,
        validator=validator.is_greater_zero,
        fixer=RETURN_DEFAULT,
    ),
    'row_count': DXFAttr(
        71, default=1, optional=True,
        validator=validator.is_greater_zero,
        fixer=RETURN_DEFAULT,
    ),
    'column_spacing': DXFAttr(44, default=0, optional=True),
    'row_spacing': DXFAttr(45, default=0, optional=True),
    'extrusion': DXFAttr(
        210, xtype=XType.point3d, default=Z_AXIS, optional=True,
        validator=validator.is_not_null_vector,
        fixer=RETURN_DEFAULT,
    ),
})
Example #11
0
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=Vec3(1, 1, 1),
            validator=validator.is_not_null_vector,
        ),
        'target':
        DXFAttr(12, xtype=XType.point3d, default=NULLVEC),
        'focal_length':
        DXFAttr(42, default=50),
        'front_clipping':
        DXFAttr(43, default=0),
        'back_clipping':
        DXFAttr(44, default=0),
        'view_twist':
        DXFAttr(50, default=0),
        'view_mode':
        DXFAttr(71, default=0),
        # Render mode:
        # 0 = 2D Optimized (classic 2D)
        # 1 = Wireframe
        # 2 = Hidden line
        # 3 = Flat shaded
        # 4 = Gouraud shaded
        # 5 = Flat shaded with wireframe
        # 6 = Gouraud shaded with wireframe
        'render_mode':
        DXFAttr(
            281,
            default=0,
            dxfversion=DXF2000,
            validator=validator.is_in_integer_range(0, 7),
            fixer=RETURN_DEFAULT,
        ),

        # 1 if there is an UCS associated to this view, 0 otherwise.
        'ucs':
        DXFAttr(
            72,
            default=0,
            validator=validator.is_integer_bool,
            fixer=RETURN_DEFAULT,
        ),
        'ucs_origin':
        DXFAttr(110, xtype=XType.point3d, dxfversion=DXF2000),
        'ucs_xaxis':
        DXFAttr(
            111,
            xtype=XType.point3d,
            dxfversion=DXF2000,
            validator=validator.is_not_null_vector,
        ),
        'ucs_yaxis':
        DXFAttr(
            112,
            xtype=XType.point3d,
            dxfversion=DXF2000,
            validator=validator.is_not_null_vector,
        ),

        # 0 = UCS is not orthographic
        # 1 = Top
        # 2 = Bottom
        # 3 = Front
        # 4 = Back
        # 5 = Left
        # 6 = Right
        'ucs_ortho_type':
        DXFAttr(
            79,
            dxfversion=DXF2000,
            validator=validator.is_in_integer_range(0, 7),
            fixer=lambda x: 0,
        ),
        'elevation':
        DXFAttr(146, dxfversion=DXF2000, default=0),

        # handle of AcDbUCSTableRecord if UCS is a named UCS. If not present,
        # then UCS is unnamed:
        'ucs_handle':
        DXFAttr(345, dxfversion=DXF2000),

        # handle of AcDbUCSTableRecord of base UCS if UCS is orthographic (79 code
        # is non-zero). If not present and 79 code is non-zero, then base UCS is
        # taken to be WORLD
        'base_ucs_handle':
        DXFAttr(346, dxfversion=DXF2000),

        # 1 if the camera is plottable
        'camera_plottable':
        DXFAttr(
            73,
            default=0,
            dxfversion=DXF2007,
            validator=validator.is_integer_bool,
            fixer=RETURN_DEFAULT,
        ),
        'background_handle':
        DXFAttr(332, optional=True, dxfversion=DXF2007),
        'live_selection_handle':
        DXFAttr(334, optional=True, dxfversion=DXF2007),
        'visual_style_handle':
        DXFAttr(348, optional=True, dxfversion=DXF2007),
        'sun_handle':
        DXFAttr(361, optional=True, dxfversion=DXF2010),
    })
Example #12
0
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.tau),  # this value is 2*pi for a full ellipse
    })

HALF_PI = math.pi / 2.0


@register_entity
class Ellipse(DXFGraphic):
    """ DXF ELLIPSE entity """
Example #13
0
dimension_subclass = DefSubclass(
    'AcDbDimension',
    {
        'geometry': DXFAttr(
            2
        ),  # name of pseudo-Block containing the current dimension  entity geometry
        'dimstyle': DXFAttr(3, default='STANDARD'),  # dimension style name
        # The dimension style is stored in Drawing.sections.tables.dimstyles,
        # shortcut Drawings.dimstyles property
        'defpoint':
        DXFAttr(10, xtype=XType.point3d,
                default=(0.0, 0.0,
                         0.0)),  # definition point for all dimension types
        'text_midpoint': DXFAttr(
            11, xtype=XType.any_point),  # midpoint of dimension text
        '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
        # (value 32 is always set in R13 and later releases)
        # 0 = Rotated, horizontal, or vertical;
        # 1 = Aligned
        # 2 = Angular;
        # 3 = Diameter;
        # 4 = Radius
        # 5 = Angular 3 point;
        # 6 = Ordinate
        # 32 = Indicates that the block reference (group code 2) is referenced by this dimension only
        # 64 = Ordinate type. This is a bit value (bit 7) used only with integer
        # value 6. If set, ordinate is X-type; if not set, ordinate is Y-type
        # 128 = This is a bit value (bit 8) added to the other group 70 values if
        # the dimension text has been positioned at a user-defined location
        # rather than at the default location
        'attachment_point': DXFAttr(71),  # Attachment point:
        # 1 = Top left; 2 = Top center; 3 = Top right
        # 4 = Middle left; 5 = Middle center; 6 = Middle right
        # 7 = Bottom left; 8 = Bottom center; 9 = Bottom right
        'line_spacing_style': DXFAttr(
            72, default=1),  # Dimension text line-spacing style (optional):
        # 1 (or missing) = At least (taller characters will override)
        # 2 = Exact (taller characters will not override)
        'line_spacing_factor':
        DXFAttr(41),  # Dimension text-line spacing factor (optional):
        # Percentage of default (3-on-5) line spacing to be applied. Valid values
        # range from 0.25 to 4.00
        'actual_measurement':
        DXFAttr(42),  # Actual measurement (optional; read-only value)
        'text':
        DXFAttr(1),  # Dimension text explicitly entered by the user. Optional;
        # default is the measurement.
        # If null or “<>”, the dimension measurement is drawn as the text,
        # if “ “ (one blank space), the text is suppressed.
        # Anything else is drawn as the text.
        'oblique_angle': DXFAttr(
            52, default=0
        ),  # Linear dimension types with an oblique angle have an optional group
        # code 52. When added to the rotation angle of the linear dimension (group code 50), it gives the angle of the
        # extension lines (DXF reference error: false subclass AcDbAlignedDimension)
        'text_rotation': DXFAttr(
            53, default=0
        ),  # The optional group code 53 is the rotation angle of the dimension
        # text away from its default orientation (the direction of the dimension line) (optional)
        'horizontal_direction': DXFAttr(
            51, default=0
        ),  # All dimension types have an optional 51 group code, which
        # indicates the horizontal direction for the dimension entity. The dimension entity determines the orientation of
        # dimension text and lines for horizontal, vertical, and rotated linear dimensions. This group value is the negative
        # of the angle between the OCS X axis and the UCS X axis. It is always in the XY plane of the OCS
        'extrusion': DXFAttr(210, xtype=XType.point3d,
                             default=(0.0, 0.0, 1.0)),
    })
Example #14
0
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),
    'n_smooth_density': DXFAttr(74, default=0, optional=True),
    # Curves and smooth surface type; integer codes, not bit-coded:
    'smooth_type': DXFAttr(75, default=0, optional=True),
    # 0 = No smooth surface fitted
    # 5 = Quadratic B-spline surface
    # 6 = Cubic B-spline surface
    # 8 = Bezier surface
    'thickness': DXFAttr(39, default=0, optional=True),
    'extrusion': DXFAttr(210, xtype=XType.point3d, default=Vector(0, 0, 1), optional=True),
})
Example #15
0
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
Example #16
0
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':
        DXFAttr(13, xtype=XType.point2d),

        # Hard reference to image def object
        'image_def_handle':
        DXFAttr(340),

        # Image display properties:
        # 1 = Show image
        # 2 = Show image when not aligned with screen
        # 4 = Use clipping boundary
        # 8 = Transparency is on
        'flags':
        DXFAttr(70, default=3),

        # Clipping state:
        # 0 = Off
        # 1 = On
        'clipping':
        DXFAttr(
            280,
            default=0,
            validator=validator.is_integer_bool,
            fixer=RETURN_DEFAULT,
        ),

        # Brightness value (0-100; default = 50)
        'brightness':
        DXFAttr(
            281,
            default=50,
            validator=validator.is_in_integer_range(0, 101),
            fixer=validator.fit_into_integer_range(0, 101),
        ),

        # Contrast value (0-100; default = 50)
        'contrast':
        DXFAttr(
            282,
            default=50,
            validator=validator.is_in_integer_range(0, 101),
            fixer=validator.fit_into_integer_range(0, 101),
        ),
        # Fade value (0-100; default = 0)
        'fade':
        DXFAttr(
            283,
            default=0,
            validator=validator.is_in_integer_range(0, 101),
            fixer=validator.fit_into_integer_range(0, 101),
        ),

        # Hard reference to image def reactor object, not required by AutoCAD
        'image_def_reactor_handle':
        DXFAttr(360),

        # Clipping boundary type:
        # 1 = Rectangular
        # 2 = Polygonal
        'clipping_boundary_type':
        DXFAttr(71,
                default=1,
                validator=validator.is_one_of({1, 2}),
                fixer=RETURN_DEFAULT),

        # Number of clip boundary vertices that follow
        'count_boundary_points':
        DXFAttr(91),

        # Clip mode:
        # 0 = outside
        # 1 = inside mode
        'clip_mode':
        DXFAttr(
            290,
            dxfversion=DXF2010,
            default=0,
            validator=validator.is_integer_bool,
            fixer=RETURN_DEFAULT,
        ),
        # boundary path coordinates are pixel coordinates NOT drawing units
    })
Example #17
0
acdb_blockrec = DefSubclass('AcDbBlockTableRecord', {
    'name': DXFAttr(2),
    'layout': DXFAttr(340, default='0'),  # handle to associated DXF LAYOUT object
    'explode': DXFAttr(280, default=1, dxfversion=DXF2007),  # 0 = can not explode; 1 = can explode
    'scale': DXFAttr(281, default=0, dxfversion=DXF2007),  # 0 = scale non uniformly; 1 = scale uniformly
    'units': DXFAttr(70, default=0, dxfversion=DXF2007),  # ezdxf.InsertUnits
    # 0 = Unitless
    # 1 = Inches
    # 2 = Feet
    # 3 = Miles
    # 4 = Millimeters
    # 5 = Centimeters
    # 6 = Meters
    # 7 = Kilometers
    # 8 = Microinches
    # 9 = Mils
    # 10 = Yards
    # 11 = Angstroms
    # 12 = Nanometers
    # 13 = Microns
    # 14 = Decimeters
    # 15 = Decameters
    # 16 = Hectometers
    # 17 = Gigameters
    # 18 = Astronomical units
    # 19 = Light years
    # 20 = Parsecs
    # 21 = US Survey Feet
    # 22 = US Survey Inch
    # 23 = US Survey Yard
    # 24 = US Survey Mile
    # ---------------------
    # 310: Binary data for bitmap preview (optional) - removed (ignored) by ezdxf
})
Example #18
0
__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,
        ),
        # 340: Hard-pointer handle to entity in group (one entry per object)
    },
)
acdb_group_group_codes = group_code_mapping(acdb_group)
GROUP_ITEM_CODE = 340
Example #19
0
acdb_style = DefSubclass('AcDbTextStyleTableRecord', {
    'name': DXFAttr(
        2, default='Standard',
        validator=validator.is_valid_table_name,
    ),
    # Flags: Standard flag values (bit-coded values):
    # 1 = If set, this entry describes a shape
    # 4 = Vertical text
    # 16 = If set, table entry is externally dependent on an xref
    # 32 = If both this bit and bit 16 are set, the externally dependent xref ...
    # 64 = If set, the table entry was referenced by at least one entity in ...
    # Vertical text works only for SHX fonts in AutoCAD and BricsCAD
    'flags': DXFAttr(70, default=0),

    # Fixed height, 0 if not fixed
    'height': DXFAttr(
        40, default=0,
        validator=validator.is_greater_or_equal_zero,
        fixer=RETURN_DEFAULT,
    ),
    # Width factor:  a.k.a. "Stretch"
    'width': DXFAttr(
        41, default=1,
        validator=validator.is_greater_zero,
        fixer=RETURN_DEFAULT,
    ),
    # Oblique angle in degree, 0 = vertical
    'oblique': DXFAttr(50, default=0),

    # Generation flags:
    # 2 = backward
    # 4 = mirrored in Y
    'generation_flags': DXFAttr(71, default=0),

    # Last height used:
    'last_height': DXFAttr(42, default=2.5),

    # Primary font file name:
    'font': DXFAttr(3, default='txt'),

    # Big font name, blank if none
    'bigfont': DXFAttr(4, default=''),
})
Example #20
0
# Copyright (c) 2019, Manfred Moitzi
# License: MIT-License
# Created: 2019-03-11
from typing import TYPE_CHECKING, List
from ezdxf.lldxf.const import SUBCLASS_MARKER, DXFStructureError
from ezdxf.lldxf.attributes import DXFAttributes, DefSubclass, DXFAttr
from .dxfentity import base_class, SubclassProcessor
from .dxfobj import DXFObject
from .factory import register_entity

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

__all__ = ['IDBuffer', 'FieldList', 'LayerFilter']

acdb_id_buffer = DefSubclass('AcDbIdBuffer', {})


@register_entity
class IDBuffer(DXFObject):
    """ DXF IDBUFFER entity """
    DXFTYPE = 'IDBUFFER'
    DXFATTRIBS = DXFAttributes(base_class, acdb_id_buffer)

    def __init__(self, doc: 'Drawing' = None):
        super().__init__(doc)
        self.handles = []  # type: List[str]

    def _copy_data(self, entity: 'IDBuffer') -> None:
        """ Copy handles """
        entity.handles = list(self.handles)
Example #21
0
# Created: 22.03.2011
# Copyright (c) 2011-2018, Manfred Moitzi
# License: MIT-License
from __future__ import unicode_literals

from ezdxf.lldxf.extendedtags import ExtendedTags
from ezdxf.lldxf.attributes import DXFAttr, DXFAttributes, DefSubclass
from ezdxf.dxfentity import DXFEntity

none_subclass = DefSubclass(None, {
    'handle': DXFAttr(5),
    'owner': DXFAttr(330),
})


class DXFClass(DXFEntity):
    __slots__ = ()
    DXFATTRIBS = DXFAttributes(
        DefSubclass(
            None, {
                'name': DXFAttr(1),
                'cpp_class_name': DXFAttr(2),
                'app_name': DXFAttr(3),
                'flags': DXFAttr(90),
                'instance_count': DXFAttr(91, dxfversion='AC1018'),
                'was_a_proxy': DXFAttr(280),
                'is_an_entity': DXFAttr(281),
            }), )


class DXFObject(DXFEntity):
Example #22
0
from ezdxf.lldxf.const import INVALID_NAME_CHARACTERS
from ezdxf.entities.dxfentity import base_class, SubclassProcessor, DXFEntity
from ezdxf.lldxf.validator import is_valid_layer_name
from ezdxf.tools import rgb2int, int2rgb, transparency2float, float2transparency
from ezdxf.lldxf.const import DXFValueError, DXFTableEntryError

from .factory import register_entity

logger = logging.getLogger('ezdxf')

if TYPE_CHECKING:
    from ezdxf.eztypes import TagWriter, DXFNamespace

__all__ = ['Layer']

acdb_symbol_table_record = DefSubclass('AcDbSymbolTableRecord', {})

acdb_layer_table_record = DefSubclass(
    'AcDbLayerTableRecord',
    {
        'name': DXFAttr(2),  # layer name
        'flags': DXFAttr(70, default=0),
        'color': DXFAttr(62, default=7),  # dxf color index
        'true_color': DXFAttr(420, dxfversion=DXF2004,
                              optional=True),  # true color
        'linetype': DXFAttr(6, default='Continuous'),  # linetype name
        'plot': DXFAttr(290, default=1, dxfversion=DXF2000,
                        optional=True),  # don't plot this layer if 0 else 1
        'lineweight': DXFAttr(
            370, default=-3,
            dxfversion=DXF2000),  # 1/100 mm, min 13 = 0.13mm, max 200 = 2.0mm
Example #23
0
acdb_text = DefSubclass(
    'AcDbText',
    {
        'insert':
        DXFAttr(10, xtype=XType.point3d, default=Vector(
            0, 0, 0)),  # First alignment point (in OCS)
        'height':
        DXFAttr(40, default=2.5, optional=True),  # Text height
        'text':
        DXFAttr(1, default=''),  # Default value (the string itself)
        'rotation':
        DXFAttr(50, default=0, optional=True
                ),  # Text rotation (optional) in degrees (circle = 360deg)
        'oblique':
        DXFAttr(51, default=0, optional=True
                ),  # Oblique angle (optional) in degrees, vertical = 0deg
        'style':
        DXFAttr(7, default='Standard',
                optional=True),  # Text style name (optional)
        'width':
        DXFAttr(41, default=1,
                optional=True),  # Relative X scale factor—width (optional)
        # This value is also adjusted when fit-type text is used
        'text_generation_flag':
        DXFAttr(71, default=0,
                optional=True),  # Text generation flags (optional)
        # 2 = backward (mirror-x),
        # 4 = upside down (mirror-y)

        # Horizontal text justification type (optional) horizontal justification
        'halign':
        DXFAttr(72, default=0, optional=True),
        # 0 = Left
        # 2 = Right
        # 3 = Aligned (if vertical alignment = 0)
        # 4 = Middle (if vertical alignment = 0)
        # 5 = Fit (if vertical alignment = 0)

        # This value is meaningful only if the value of a 72 or 73 group is nonzero (if the justification is anything other
        # than baseline/left)
        'align_point':
        DXFAttr(11, xtype=XType.point3d,
                optional=True),  # Second alignment point (in OCS) (optional)
        'thickness':
        DXFAttr(39, default=0, optional=True),  # Thickness (optional)
        # Extrusion direction (optional)
        'extrusion':
        DXFAttr(
            210, xtype=XType.point3d, default=Vector(0, 0, 1), optional=True),
    })
Example #24
0
if TYPE_CHECKING:
    from ezdxf.eztypes import TagWriter, DXFNamespace

__all__ = ["Line"]

acdb_line = DefSubclass(
    "AcDbLine",
    {
        "start":
        DXFAttr(10, xtype=XType.point3d, default=NULLVEC),
        "end":
        DXFAttr(11, xtype=XType.point3d, default=NULLVEC),
        "thickness":
        DXFAttr(39, default=0, optional=True),
        "extrusion":
        DXFAttr(
            210,
            xtype=XType.point3d,
            default=Z_AXIS,
            optional=True,
            validator=validator.is_not_null_vector,
            fixer=RETURN_DEFAULT,
        ),
    },
)

acdb_line_group_codes = group_code_mapping(acdb_line)
merged_line_group_codes = merge_group_code_mappings(
    acdb_entity_group_codes,
    acdb_line_group_codes  # type: ignore
)
Example #25
0
acdb_leader = DefSubclass(
    'AcDbLeader',
    {
        'dimstyle':
        DXFAttr(
            3,
            default='Standard',
            validator=validator.is_valid_table_name,
            # no fixer!
        ),

        # Arrowhead flag: 0/1 = no/yes
        'has_arrowhead':
        DXFAttr(
            71,
            default=1,
            optional=True,
            validator=validator.is_integer_bool,
            fixer=RETURN_DEFAULT,
        ),

        # Leader path type:
        # 0 = Straight line segments
        # 1 = Spline
        'path_type':
        DXFAttr(
            72,
            default=0,
            optional=True,
            validator=validator.is_integer_bool,
            fixer=RETURN_DEFAULT,
        ),

        # Annotation type or leader creation flag:
        # 0 = Created with text annotation
        # 1 = Created with tolerance annotation;
        # 2 = Created with block reference annotation
        # 3 = Created without any annotation
        'annotation_type':
        DXFAttr(
            73,
            default=3,
            validator=validator.is_in_integer_range(0, 4),
            fixer=RETURN_DEFAULT,
        ),

        # Hook line direction flag:
        # 1 = Hook line (or end of tangent for a spline leader) is the opposite
        #     direction from the horizontal vector
        # 0 = Hook line (or end of tangent for a spline leader) is the same
        #     direction as horizontal vector (see code 75)
        # DXF reference error: swapped meaning of 1/0
        'hookline_direction':
        DXFAttr(
            74,
            default=1,
            optional=True,
            validator=validator.is_integer_bool,
            fixer=RETURN_DEFAULT,
        ),

        # Hook line flag: 0/1 = no/yes
        'has_hookline':
        DXFAttr(
            75,
            default=1,
            optional=True,
            validator=validator.is_integer_bool,
            fixer=RETURN_DEFAULT,
        ),

        # Text annotation height:
        'text_height':
        DXFAttr(
            40,
            default=1,
            optional=True,
            validator=validator.is_greater_zero,
            fixer=RETURN_DEFAULT,
        ),

        # Text annotation width:
        'text_width':
        DXFAttr(
            41,
            default=1,
            optional=True,
            validator=validator.is_greater_zero,
            fixer=RETURN_DEFAULT,
        ),

        # 76: Number of vertices in leader (ignored for OPEN)
        # 10, 20, 30: Vertex coordinates (one entry for each vertex)

        # Color to use if leader's DIMCLRD = BYBLOCK
        'block_color':
        DXFAttr(
            77,
            default=7,
            optional=True,
            validator=validator.is_valid_aci_color,
            fixer=RETURN_DEFAULT,
        ),

        # Hard reference to associated annotation:
        # (mtext, tolerance, or insert entity)
        'annotation_handle':
        DXFAttr(340, default='0', optional=True),
        'normal_vector':
        DXFAttr(
            210,
            xtype=XType.point3d,
            default=Z_AXIS,
            optional=True,
            validator=validator.is_not_null_vector,
            fixer=RETURN_DEFAULT,
        ),

        # 'horizontal' direction for leader
        'horizontal_direction':
        DXFAttr(
            211,
            xtype=XType.point3d,
            default=X_AXIS,
            optional=True,
            validator=validator.is_not_null_vector,
            fixer=RETURN_DEFAULT,
        ),

        # Offset of last leader vertex from block reference insertion point
        'leader_offset_block_ref':
        DXFAttr(212, xtype=XType.point3d, default=NULLVEC, optional=True),

        # Offset of last leader vertex from annotation placement point
        'leader_offset_annotation_placement':
        DXFAttr(213, xtype=XType.point3d, default=NULLVEC, optional=True),

        # Xdata belonging to the application ID "ACAD" follows a leader entity if
        # any dimension overrides have been applied to this entity. See Dimension
        # Style Overrides.
    })
Example #26
0
# If tag 90 is not the first TAG, AutoCAD does not close the polyline, when the
# `close` flag is set.
acdb_lwpolyline = DefSubclass('AcDbPolyline', {
    # Count always returns the actual length:
    'count': DXFAttr(90, xtype=XType.callback, getter='__len__'),

    # Elevation: OCS z-axis value for all vertices:
    'elevation': DXFAttr(38, default=0, optional=True),

    # Thickness can be negative!
    'thickness': DXFAttr(39, default=0, optional=True),

    # Flags:
    # 1 = Closed
    # 128 = Plinegen
    'flags': DXFAttr(70, default=0),

    # Const width: DXF reference error - AutoCAD uses just const width if not 0,
    # for all line segments.
    'const_width': DXFAttr(43, default=0, optional=True),
    'extrusion': DXFAttr(
        210, xtype=XType.point3d, default=Z_AXIS, optional=True,
        validator=validator.is_not_null_vector,
        fixer=RETURN_DEFAULT,
    ),
    # 10, 20 : Vertex x, y
    # 91: vertex identifier ???
    # 40, 41, 42: start width, end width, bulge
})

acdb_lwpolyline_group_codes = group_code_mapping(acdb_lwpolyline)
Example #27
0
logger = logging.getLogger('ezdxf')

if TYPE_CHECKING:
    from ezdxf.eztypes import TagWriter, DXFNamespace

__all__ = ['UCSTable']

acdb_ucs = DefSubclass('AcDbUCSTableRecord', {
    'name': DXFAttr(2, validator=validator.is_valid_table_name),
    'flags': DXFAttr(70, default=0),
    'origin': DXFAttr(10, xtype=XType.point3d, default=NULLVEC),
    'xaxis': DXFAttr(
        11, xtype=XType.point3d, default=X_AXIS,
        validator=validator.is_not_null_vector,
        fixer=RETURN_DEFAULT,
    ),
    'yaxis': DXFAttr(
        12, xtype=XType.point3d, default=Y_AXIS,
        validator=validator.is_not_null_vector,
        fixer=RETURN_DEFAULT,
    ),
})


@register_entity
class UCSTable(DXFEntity):
    """ DXF UCS table entity """
    DXFTYPE = 'UCS'
    DXFATTRIBS = DXFAttributes(base_class, acdb_symbol_table_record, acdb_ucs)
Example #28
0
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),
            fixer=RETURN_DEFAULT,
        ),
        # 310: Binary data for bitmap preview (optional) - removed (ignored) by ezdxf
    },
)
Example #29
0
__all__ = ['Circle']

acdb_circle = DefSubclass(
    'AcDbCircle',
    {
        'center':
        DXFAttr(10, xtype=XType.point3d, default=NULLVEC),
        # AutCAD/BricsCAD: Radius is <= 0 is valid
        'radius':
        DXFAttr(40, default=1),

        # Elevation is a legacy feature from R11 and prior, do not use this
        # attribute, store the entity elevation in the z-axis of the vertices.
        # ezdxf does not export the elevation attribute!
        'elevation':
        DXFAttr(38, default=0, optional=True),
        'thickness':
        DXFAttr(39, default=0, optional=True),
        'extrusion':
        DXFAttr(
            210,
            xtype=XType.point3d,
            default=Z_AXIS,
            optional=True,
            validator=validator.is_not_null_vector,
            fixer=RETURN_DEFAULT,
        ),
    })


@register_entity
Example #30
0
acdb_text = DefSubclass(
    'AcDbText',
    {
        # First alignment point (in OCS):
        'insert':
        DXFAttr(10, xtype=XType.point3d, default=NULLVEC),

        # Text height
        'height':
        DXFAttr(
            40,
            default=2.5,
            validator=validator.is_greater_zero,
            fixer=RETURN_DEFAULT,
        ),

        # Text content as sting:
        'text':
        DXFAttr(
            1,
            default='',
            validator=validator.is_valid_one_line_text,
            fixer=validator.fix_one_line_text,
        ),

        # Text rotation in degrees (optional)
        'rotation':
        DXFAttr(50, default=0, optional=True),

        # Oblique angle in degrees, vertical = 0 deg (optional)
        'oblique':
        DXFAttr(51, default=0, optional=True),

        # Text style name (optional), given text style must have an entry in the
        # text-styles tables.
        'style':
        DXFAttr(7, default='Standard', optional=True),

        # Relative X scale factor—width (optional)
        # This value is also adjusted when fit-type text is used
        'width':
        DXFAttr(
            41,
            default=1,
            optional=True,
            validator=validator.is_greater_zero,
            fixer=RETURN_DEFAULT,
        ),

        # Text generation flags (optional)
        # 2 = backward (mirror-x),
        # 4 = upside down (mirror-y)
        'text_generation_flag':
        DXFAttr(
            71,
            default=0,
            optional=True,
            validator=validator.is_one_of({0, 2, 4, 6}),
            fixer=RETURN_DEFAULT,
        ),

        # Horizontal text justification type (optional) horizontal justification
        # 0 = Left
        # 1 = Center
        # 2 = Right
        # 3 = Aligned (if vertical alignment = 0)
        # 4 = Middle (if vertical alignment = 0)
        # 5 = Fit (if vertical alignment = 0)
        # This value is meaningful only if the value of a 72 or 73 group is nonzero
        # (if the justification is anything other than baseline/left)
        'halign':
        DXFAttr(72,
                default=0,
                optional=True,
                validator=validator.is_in_integer_range(0, 6),
                fixer=RETURN_DEFAULT),

        # Second alignment point (in OCS) (optional)
        'align_point':
        DXFAttr(11, xtype=XType.point3d, optional=True),

        # Thickness in extrusion direction, only supported for SHX font in
        # AutoCAD/BricsCAD (optional), can be negative
        'thickness':
        DXFAttr(39, default=0, optional=True),

        # Extrusion direction (optional)
        'extrusion':
        DXFAttr(210,
                xtype=XType.point3d,
                default=Z_AXIS,
                optional=True,
                validator=validator.is_not_null_vector,
                fixer=RETURN_DEFAULT),
    })