コード例 #1
0
class Solid3d(Body):
    """ DXF 3DSOLID entity - container entity for embedded ACIS data. """
    DXFTYPE = '3DSOLID'
    DXFATTRIBS = DXFAttributes(
        base_class, acdb_entity, acdb_modeler_geometry, acdb_3dsolid)

    def load_dxf_attribs(
            self, processor: SubclassProcessor = None) -> 'DXFNamespace':
        dxf = super().load_dxf_attribs(processor)
        if processor:
            processor.fast_load_dxfattribs(dxf, acdb_3dsolid_group_codes, 3)
        return dxf

    def export_entity(self, tagwriter: 'TagWriter') -> None:
        """ Export entity specific data as DXF tags. """
        # base class export is done by parent class
        super().export_entity(tagwriter)
        # AcDbEntity export is done by parent class
        # AcDbModelerGeometry export is done by parent class
        tagwriter.write_tag2(SUBCLASS_MARKER, acdb_3dsolid.name)
        self.dxf.export_dxf_attribs(tagwriter, 'history_handle')
コード例 #2
0
ファイル: image.py プロジェクト: vshu3000/ezdxf
class ImageDefReactor(DXFObject):
    """ DXF IMAGEDEF_REACTOR entity """
    DXFTYPE = 'IMAGEDEF_REACTOR'
    DXFATTRIBS = DXFAttributes(base_class, acdb_image_def_reactor)
    MIN_DXF_VERSION_FOR_EXPORT = DXF2000

    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_image_def_reactor)
            if len(tags):
                processor.log_unprocessed_tags(tags, subclass=acdb_image_def_reactor.name)
        return dxf

    def export_entity(self, tagwriter: 'TagWriter') -> None:
        """ Export entity specific data as DXF tags. """
        # base class export is done by parent class
        super().export_entity(tagwriter)
        tagwriter.write_tag2(SUBCLASS_MARKER, acdb_image_def_reactor.name)
        tagwriter.write_tag2(90, self.dxf.class_version)
        tagwriter.write_tag2(330, self.dxf.image_handle)
コード例 #3
0
class DXFLayout(PlotSettings):
    DXFTYPE = 'LAYOUT'
    DXFATTRIBS = DXFAttributes(base_class, acdb_plot_settings, acdb_layout)

    def load_dxf_attribs(self, processor: SubclassProcessor = None) -> 'DXFNamespace':
        dxf = super().load_dxf_attribs(processor)
        if processor is None:
            return dxf

        processor.load_dxfattribs_into_namespace(dxf, acdb_layout)
        return dxf

    def export_entity(self, tagwriter: 'TagWriter') -> None:
        # base class export is done by parent class
        super().export_entity(tagwriter)
        tagwriter.write_tag2(SUBCLASS_MARKER, acdb_layout.name)
        self.dxf.export_dxf_attribs(tagwriter, [
            'name', 'layout_flags', 'taborder', 'limmin', 'limmax', 'insert_base', 'extmin', 'extmax', 'elevation',
            'ucs_origin', 'ucs_xaxis', 'ucs_yaxis', 'ucs_type', 'block_record_handle', 'viewport_handle', 'ucs_handle',
            'base_ucs_handle',
        ])
コード例 #4
0
class MLeaderStyle(DXFObject):
    DXFTYPE = 'MLEADERSTYLE'
    DXFATTRIBS = DXFAttributes(base_class, acdb_mleader_style)
    MIN_DXF_VERSION_FOR_EXPORT = const.DXF2000

    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_mleader_style)
            if len(tags):
                processor.log_unprocessed_tags(
                    tags, subclass=acdb_mleader_style.name)
        return dxf

    def export_entity(self, tagwriter: 'TagWriter') -> None:
        super().export_entity(tagwriter)
        tagwriter.write_tag2(const.SUBCLASS_MARKER, acdb_mleader_style.name)
        self.dxf.export_dxf_attribs(
            tagwriter, acdb_mleader_style.attribs.keys())
コード例 #5
0
class WipeoutVariables(DXFObject):
    """ DXF WIPEOUTVARIABLES entity """
    DXFTYPE = 'WIPEOUTVARIABLES'
    DXFATTRIBS = DXFAttributes(base_class, acdb_wipeout_variables)
    MIN_DXF_VERSION_FOR_EXPORT = DXF2000

    def load_dxf_attribs(self,
                         processor: SubclassProcessor = None
                         ) -> 'DXFNamespace':
        dxf = super().load_dxf_attribs(processor)
        if processor:
            processor.fast_load_dxfattribs(dxf,
                                           acdb_wipeout_variables_group_codes,
                                           1)
        return dxf

    def export_entity(self, tagwriter: 'TagWriter') -> None:
        """ Export entity specific data as DXF tags. """
        super().export_entity(tagwriter)
        tagwriter.write_tag2(SUBCLASS_MARKER, acdb_wipeout_variables.name)
        self.dxf.export_dxf_attribs(tagwriter, 'frame')
コード例 #6
0
ファイル: line.py プロジェクト: k3rn3l3rr0r/ezdxf
class Line(DXFGraphic):
    """ The LINE entity represents a 3D line from `start` to `end` """
    DXFTYPE = 'LINE'
    DXFATTRIBS = DXFAttributes(base_class, acdb_entity, acdb_line)

    def load_dxf_attribs(self,
                         processor: SubclassProcessor = None
                         ) -> 'DXFNamespace':
        """
        Adds subclass processing for 'AcDbLine', requires previous base class and 'AcDbEntity' processing by parent
        class. (internal API)
        """
        dxf = super().load_dxf_attribs(processor)
        if processor:
            tags = processor.load_dxfattribs_into_namespace(dxf, acdb_line)
            if len(tags) and not processor.r12:
                processor.log_unprocessed_tags(tags, subclass=acdb_line.name)
        return dxf

    def export_entity(self, tagwriter: 'TagWriter') -> None:
        """ Export entity specific data as DXF tags. (internal API) """
        # base class export is done by parent class
        super().export_entity(tagwriter)
        # AcDbEntity export is done by parent class
        if tagwriter.dxfversion > DXF12:
            tagwriter.write_tag2(SUBCLASS_MARKER, acdb_line.name)
        # for all DXF versions
        self.dxf.export_dxf_attribs(tagwriter,
                                    ['start', 'end', 'thickness', 'extrusion'])
        # xdata and embedded objects export will be done by parent class

    def transform_to_wcs(self, ucs: UCS) -> None:
        """ Transform LINE entity from local :class:`~ezdxf.math.UCS` coordinates to
        :ref:`WCS` coordinates.

        .. versionadded:: 0.11

        """
        self.dxf.start = ucs.to_wcs(self.dxf.start)
        self.dxf.end = ucs.to_wcs(self.dxf.end)
コード例 #7
0
class Solid(_Base):
    """ DXF SHAPE entity """
    DXFTYPE = 'SOLID'
    DXFATTRIBS = DXFAttributes(base_class, acdb_entity, acdb_trace)

    def __getitem__(self, num):
        return self.dxf.get(VERTEXNAMES[num])

    def __setitem__(self, num, value):
        return self.dxf.set(VERTEXNAMES[num], value)

    def load_dxf_attribs(self,
                         processor: SubclassProcessor = None
                         ) -> 'DXFNamespace':
        """ Loading interface. (internal API) """
        dxf = super().load_dxf_attribs(processor)
        if processor:
            tags = processor.load_dxfattribs_into_namespace(dxf, acdb_trace)
            if len(tags) and not processor.r12:
                processor.log_unprocessed_tags(tags, acdb_trace.name)
        return dxf

    def export_entity(self, tagwriter: 'TagWriter') -> None:
        """ Export entity specific data as DXF tags. (internal API) """
        # base class export is done by parent class
        super().export_entity(tagwriter)
        # AcDbEntity export is done by parent class
        if tagwriter.dxfversion > DXF12:
            tagwriter.write_tag2(SUBCLASS_MARKER, acdb_trace.name)
        # for all DXF versions
        if not self.dxf.hasattr('vtx3'):
            self.dxf.vtx3 = self.dxf.vtx2
        self.dxf.export_dxf_attribs(tagwriter, [
            'vtx0',
            'vtx1',
            'vtx2',
            'vtx3',
            'thickness',
            'extrusion',
        ])
コード例 #8
0
class VBAProject(DXFObject):
    """ DXF VBA_PROJECT entity """
    DXFTYPE = 'VBA_PROJECT'
    DXFATTRIBS = DXFAttributes(base_class, acdb_vba_project)

    def __init__(self, doc: 'Drawing' = None):
        super().__init__(doc)
        self.data = b''

    def _copy_data(self, entity: 'VBAProject') -> None:
        entity.tags = Tags(entity.tags)

    def load_dxf_attribs(self, processor: SubclassProcessor = None) -> 'DXFNamespace':
        dxf = super().load_dxf_attribs(processor)
        if processor:
            self.load_byte_data(processor.subclasses[1])
        return dxf

    def load_byte_data(self, tags: 'Tags') -> None:
        byte_array = array.array('B')
        for byte_data in (tag.value for tag in tags if tag.code == 310):
            byte_array.extend(byte_data)
        self.data = byte_array.tobytes()

    def export_entity(self, tagwriter: 'TagWriter') -> None:
        # base class export is done by parent class
        super().export_entity(tagwriter)
        # AcDbEntity export is done by parent class
        tagwriter.write_tag2(SUBCLASS_MARKER, acdb_vba_project.name)
        tagwriter.write_tag2(90, len(self.data))
        self.export_data(tagwriter)

    def export_data(self, tagwriter: 'TagWriter'):
        data = self.data
        while data:
            tagwriter.write_tag(DXFBinaryTag(310, data[:127]))
            data = data[127:]

    def clear(self) -> None:
        self.data = b''
コード例 #9
0
ファイル: helix.py プロジェクト: mhenr18/ezdxf
class Helix(Spline):
    """ DXF HELIX entity """
    DXFTYPE = 'HELIX'
    DXFATTRIBS = DXFAttributes(base_class, acdb_entity, acdb_spline,
                               acdb_helix)

    def load_dxf_attribs(self,
                         processor: SubclassProcessor = None
                         ) -> 'DXFNamespace':
        dxf = super().load_dxf_attribs(processor)
        if processor:
            processor.fast_load_dxfattribs(dxf,
                                           acdb_helix_group_codes,
                                           3,
                                           recover=True)
        return dxf

    def export_entity(self, tagwriter: 'TagWriter') -> None:
        """ Export entity specific data as DXF tags. """
        super().export_entity(tagwriter)
        tagwriter.write_tag2(SUBCLASS_MARKER, acdb_helix.name)
        self.dxf.export_dxf_attribs(tagwriter, [
            'major_release_number', 'maintenance_release_number',
            'axis_base_point', 'start_point', 'axis_vector', 'radius', 'turns',
            'turn_height', 'handedness', 'constrain'
        ])

    def transform(self, m: 'Matrix44') -> 'Helix':
        """ Transform HELIX entity by transformation matrix `m` inplace.

        .. versionadded:: 0.13

        """
        super().transform(m)
        self.dxf.axis_base_point = m.transform(self.dxf.axis_base_point)
        self.dxf.axis_vector = m.transform_direction(self.dxf.axis_vector)
        self.dxf.start_point = m.transform(self.dxf.start_point)
        self.dxf.radius = m.transform_direction(
            (self.dxf.radius, 0, 0)).magnitude
        return self
コード例 #10
0
ファイル: tableentries.py プロジェクト: shangulaike/ezdxf
class Linetype(legacy.Linetype):
    __slots__ = ()
    TEMPLATE = ExtendedTags.from_text(_LTYPETEMPLATE)
    DXFATTRIBS = DXFAttributes(none_subclass, symbol_subclass,
                               linetype_subclass)

    def _setup_pattern(self, pattern: Union[Iterable[float], str],
                       length: float) -> None:
        complex_line_type = True if isinstance(pattern, str) else False
        if complex_line_type:  # a .lin like line type definition string
            self._setup_complex_pattern(pattern, length)
        else:
            # pattern: [2.0, 1.25, -0.25, 0.25, -0.25] - 1. element is total pattern length
            # pattern elements: >0 line, <0 gap, =0 point
            subclass = self.tags.get_subclass('AcDbLinetypeTableRecord')
            subclass.append(DXFTag(73, len(pattern) - 1))
            subclass.append(DXFTag(40, float(pattern[0])))
            for element in pattern[1:]:
                subclass.append(DXFTag(49, float(element)))
                subclass.append(DXFTag(74, 0))

    def _setup_complex_pattern(self, pattern: str, length: float) -> None:
        tokens = lin_compiler(pattern)
        subclass = self.tags.get_subclass('AcDbLinetypeTableRecord')
        subclass.append(DXFTag(73, 0))  # temp length of 0
        subclass.append(DXFTag(40, length))
        count = 0
        for token in tokens:
            if isinstance(token, DXFTag):
                if subclass[-1].code == 49:  # useless 74 only after 49 :))
                    subclass.append(DXFTag(74, 0))
                subclass.append(token)
                count += 1
            else:  # TEXT or SHAPE
                tags = cast('ComplexLineTypePart',
                            token).complex_ltype_tags(self.drawing)
                subclass.extend(tags)
        subclass.append(DXFTag(74, 0))  # useless 74 at the end :))
        subclass.update(DXFTag(73, count))
コード例 #11
0
class Light(DXFGraphic):
    """ DXF LIGHT entity """
    DXFTYPE = 'LIGHT'
    DXFATTRIBS = DXFAttributes(base_class, acdb_entity, acdb_light)
    MIN_DXF_VERSION_FOR_EXPORT = DXF2007

    def load_dxf_attribs(self, processor: SubclassProcessor = None) -> 'DXFNamespace':
        dxf = super().load_dxf_attribs(processor)
        if processor:
            processor.load_dxfattribs_into_namespace(dxf, acdb_light)
        return dxf

    def export_entity(self, tagwriter: 'TagWriter') -> None:
        """ Export entity specific data as DXF tags. """
        # base class export is done by parent class
        super().export_entity(tagwriter)
        tagwriter.write_tag2(SUBCLASS_MARKER, acdb_light.name)
        self.dxf.export_dxf_attribs(tagwriter, [
            'version', 'name', 'type', 'status', 'plot_glyph', 'intensity', 'location', 'target', 'attenuation_type',
            'use_attenuation_limits', 'attenuation_start_limits', 'attenuation_end_limits', 'hotspot_angle',
            'falloff_angle', 'cast_shadows', 'shadow_type', 'shadow_map_size', 'shadow_map_softness'
        ])
コード例 #12
0
class ImageDef(DXFObject):
    """ DXF IMAGEDEF entity """
    DXFTYPE = 'IMAGEDEF'
    DXFATTRIBS = DXFAttributes(base_class, acdb_image_def)
    MIN_DXF_VERSION_FOR_EXPORT = DXF2000

    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_image_def)
            if len(tags):
                processor.log_unprocessed_tags(tags, subclass=acdb_image_def.name)
        return dxf

    def export_entity(self, tagwriter: 'TagWriter') -> None:
        """ Export entity specific data as DXF tags. """
        # base class export is done by parent class
        super().export_entity(tagwriter)
        tagwriter.write_tag2(SUBCLASS_MARKER, acdb_image_def.name)
        self.dxf.export_dxf_attribs(tagwriter, [
            'class_version', 'filename', 'image_size', 'pixel_size', 'loaded', 'resolution_units',
        ])
コード例 #13
0
class Surface(Body):
    """ DXF SURFACE entity - container entity for embedded ACIS data. """
    DXFTYPE = 'SURFACE'
    DXFATTRIBS = DXFAttributes(base_class, acdb_entity, acdb_modeler_geometry,
                               acdb_surface)

    def load_dxf_attribs(self,
                         processor: SubclassProcessor = None
                         ) -> 'DXFNamespace':
        dxf = super().load_dxf_attribs(processor)
        if processor:
            processor.load_dxfattribs_into_namespace(dxf, acdb_surface)
        return dxf

    def export_entity(self, tagwriter: 'TagWriter') -> None:
        """ Export entity specific data as DXF tags. """
        # base class export is done by parent class
        super().export_entity(tagwriter)
        # AcDbEntity export is done by parent class
        # AcDbModelerGeometry export is done by parent class
        tagwriter.write_tag2(SUBCLASS_MARKER, acdb_surface.name)
        self.dxf.export_dxf_attribs(tagwriter, ['u_count', 'v_count'])
コード例 #14
0
ファイル: graphics.py プロジェクト: soldocode/ezdxf
def make_attribs(additional=None):
    dxfattribs = {
        'handle': DXFAttr(5),
        'layer': DXFAttr(
            8, default='0'
        ),  # layer name as string, mandatory according to the DXF Reference
        'linetype':
        DXFAttr(6, default='BYLAYER'
                ),  # linetype as string, special names BYLAYER/BYBLOCK
        'color':
        DXFAttr(62,
                default=256),  # dxf color index, 0 .. BYBLOCK, 256 .. BYLAYER
        'thickness': DXFAttr(39, default=0),  # thickness of 2D elements
        'paperspace': DXFAttr(67, default=0),  # 0=modelspace; 1=paperspace
        'extrusion':
        DXFAttr(210, xtype='Point3D',
                default=(0.0, 0.0,
                         1.0)),  # Z-axis of OCS (Object-Coordinate-System)
    }
    if additional is not None:
        dxfattribs.update(additional)
    return DXFAttributes(DefSubclass(None, dxfattribs))
コード例 #15
0
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:
            tags = processor.load_dxfattribs_into_namespace(dxf, acdb_circle)
            if len(tags) and not processor.r12:
                processor.log_unprocessed_tags(tags, subclass=acdb_circle.name)
        return dxf

    def export_entity(self, tagwriter: 'TagWriter') -> None:
        """ Export entity specific data as DXF tags. """
        # base class export is done by parent class
        super().export_entity(tagwriter)
        # AcDbEntity export is done by parent class
        if tagwriter.dxfversion > DXF12:
            tagwriter.write_tag2(SUBCLASS_MARKER, acdb_circle.name)
        # for all DXF versions
        self.dxf.export_dxf_attribs(tagwriter, ['center', 'radius', 'thickness', 'extrusion'])
コード例 #16
0
class MLeaderStyle(DXFObject):
    DXFTYPE = 'MLEADERSTYLE'
    DXFATTRIBS = DXFAttributes(base_class, acdb_mleader_style)
    MIN_DXF_VERSION_FOR_EXPORT = DXF2004

    def copy(self):
        raise DXFTypeError('Copying of {} not supported.'.format(self.DXFTYPE))

    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_mleader_style)
            if len(tags):
                processor.log_unprocessed_tags(tags, subclass=acdb_mleader_style.name)
        return dxf

    def export_entity(self, tagwriter: 'TagWriter') -> None:
        # base class export is done by parent class
        super().export_entity(tagwriter)
        # AcDbEntity export is done by parent class
        tagwriter.write_tag2(SUBCLASS_MARKER, acdb_mleader_style.name)
        self.dxf.export_dxf_attribs(tagwriter, acdb_mleader_style.attribs.keys())
コード例 #17
0
class Helix(Spline):
    """ DXF HELIX entity """
    DXFTYPE = 'HELIX'
    DXFATTRIBS = DXFAttributes(base_class, acdb_entity, acdb_spline,
                               acdb_helix)

    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_helix)
            if len(tags):
                processor.log_unprocessed_tags(tags, subclass=acdb_helix.name)
        return dxf

    def export_entity(self, tagwriter: 'TagWriter') -> None:
        """ Export entity specific data as DXF tags. """
        # base class export is done by parent class
        super().export_entity(tagwriter)
        # AcDbEntity export is done by parent class
        tagwriter.write_tag2(SUBCLASS_MARKER, acdb_helix.name)
        self.dxf.export_dxf_attribs(tagwriter, [
            'major_release_number', 'maintenance_release_number',
            'axis_base_point', 'start_point', 'axis_vector', 'radius', 'turns',
            'turn_height', 'handedness', 'constrain'
        ])

    def transform_to_wcs(self, ucs: 'UCS') -> 'Helix':
        """ Transform HELIX entity from local :class:`~ezdxf.math.UCS` coordinates to :ref:`WCS` coordinates.

        .. versionadded:: 0.11

        """
        super().transform_to_wcs(ucs)
        self.dxf.axis_base_point = ucs.to_wcs(self.dxf.axis_base_point)
        self.dxf.axis_vector = ucs.direction_to_wcs(self.dxf.axis_vector)
        self.dxf.start_point = ucs.to_wcs(self.dxf.start_point)
        return self
コード例 #18
0
ファイル: appid.py プロジェクト: yening2020/ezdxf
class AppID(DXFEntity):
    """ DXF APPID entity """
    DXFTYPE = 'APPID'
    DXFATTRIBS = DXFAttributes(base_class, acdb_symbol_table_record, acdb_appid)

    def load_dxf_attribs(self,
                         processor: SubclassProcessor = None) -> 'DXFNamespace':
        dxf = super().load_dxf_attribs(processor)
        if processor:
            processor.fast_load_dxfattribs(
                dxf, acdb_appid_group_codes, subclass=2)
        return dxf

    def export_entity(self, tagwriter: 'TagWriter') -> None:
        super().export_entity(tagwriter)
        # AcDbEntity export is done by parent class
        if tagwriter.dxfversion > DXF12:
            tagwriter.write_tag2(SUBCLASS_MARKER, acdb_symbol_table_record.name)
            tagwriter.write_tag2(SUBCLASS_MARKER, acdb_appid.name)

        # for all DXF versions
        self.dxf.export_dxf_attribs(tagwriter, ['name', 'flags'])
コード例 #19
0
ファイル: mesh.py プロジェクト: shangulaike/ezdxf
class Mesh(ModernGraphicEntity):
    __slots__ = ()
    TEMPLATE = tag_processor(ExtendedTags.from_text(_MESH_TPL))
    DXFATTRIBS = DXFAttributes(none_subclass, entity_subclass, mesh_subclass)

    @property
    def AcDbSubDMesh(self) -> 'Tags':
        return self.tags.subclasses[2]

    @property
    def vertices(self) -> MeshVertexArray:
        return self.AcDbSubDMesh.get_first_tag(MeshVertexArray.code)

    @property
    def faces(self) -> FaceList:
        return self.AcDbSubDMesh.get_first_tag(FaceList.code)

    @property
    def edges(self) -> EdgeArray:
        return self.AcDbSubDMesh.get_first_tag(EdgeArray.code)

    @property
    def creases(self) -> CreaseArray:
        return self.AcDbSubDMesh.get_first_tag(CreaseArray.code)

    def get_data(self) -> 'MeshData':
        return MeshData(self)

    def set_data(self, data: 'MeshData') -> None:
        self.vertices.set_data(data.vertices)
        self.faces.set_data(data.faces)
        self.edges.set_data(data.edges)
        self.creases.set_data(data.edge_crease_values)

    @contextmanager
    def edit_data(self) -> 'MeshData':
        data = self.get_data()
        yield data
        self.set_data(data)
コード例 #20
0
class TableHead(DXFEntity):
    """The table head structure is only maintained for export and not for
    internal usage, ezdxf ignores an inconsistent table head at runtime.

    """

    DXFTYPE = "TABLE"
    DXFATTRIBS = DXFAttributes(base_class, acdb_symbol_table)

    def load_dxf_attribs(self,
                         processor: SubclassProcessor = None
                         ) -> "DXFNamespace":
        dxf = super().load_dxf_attribs(processor)
        if processor:
            dxf.name = processor.base_class.get_first_value(2)
            # Stored max table count is not required:
            dxf.count = 0
        return dxf

    def export_dxf(self, tagwriter: "TagWriter") -> None:
        assert self.dxf.handle, ("TABLE needs a handle, maybe loaded from "
                                 "DXF R12 without handle!")
        tagwriter.write_tag2(const.STRUCTURE_MARKER, self.DXFTYPE)
        tagwriter.write_tag2(2, self.dxf.name)
        if tagwriter.dxfversion >= const.DXF2000:
            tagwriter.write_tag2(5, self.dxf.handle)
            if self.has_extension_dict:
                self.extension_dict.export_dxf(tagwriter)  # type: ignore
            tagwriter.write_tag2(const.OWNER_CODE, self.dxf.owner)
            tagwriter.write_tag2(const.SUBCLASS_MARKER, acdb_symbol_table.name)
            tagwriter.write_tag2(70, self.dxf.count)
            # There is always one exception:
            if self.dxf.name == "DIMSTYLE":
                tagwriter.write_tag2(const.SUBCLASS_MARKER,
                                     "AcDbDimStyleTable")
        else:  # DXF R12
            # TABLE does not need a handle at all
            tagwriter.write_tag2(70, self.dxf.count)
コード例 #21
0
ファイル: table.py プロジェクト: ericgcc/ezdxf
class TableHead(DXFEntity):
    """ The table head structure is only maintained for export and not for
    internal usage, ezdxf ignores an inconsistent table head at runtime.

    A table integrity check (audit) is not necessary, because ezdxf (should)
    export only valid table structures (table head).

    """
    DXFTYPE = 'TABLE'
    DXFATTRIBS = DXFAttributes(base_class, acdb_symbol_table)

    def load_dxf_attribs(
            self, processor: SubclassProcessor = None) -> 'DXFNamespace':
        dxf = super().load_dxf_attribs(processor)
        if processor:
            dxf.name = processor.base_class.get_first_value(2)
            # Stored max table count is not required:
            dxf.count = 0
        return dxf

    def export_dxf(self, tagwriter: 'TagWriter') -> None:
        assert self.dxf.handle, 'TABLE needs a handle, maybe loaded from ' \
                                'DXF R12 without handle!'
        tagwriter.write_tag2(STRUCTURE_MARKER, self.DXFTYPE)
        tagwriter.write_tag2(2, self.dxf.name)
        if tagwriter.dxfversion >= DXF2000:
            tagwriter.write_tag2(5, self.dxf.handle)
            if self.has_extension_dict:
                self.extension_dict.export_dxf(tagwriter)
            tagwriter.write_tag2(OWNER_CODE, self.dxf.owner)
            tagwriter.write_tag2(SUBCLASS_MARKER, acdb_symbol_table.name)
            tagwriter.write_tag2(70, self.dxf.count)
            # There is always one exception:
            if self.dxf.name == 'DIMSTYLE':
                tagwriter.write_tag2(SUBCLASS_MARKER, 'AcDbDimStyleTable')
        else:  # DXF R12
            # TABLE does not need a handle at all
            tagwriter.write_tag2(70, self.dxf.count)
コード例 #22
0
class Tolerance(DXFGraphic):
    """ DXF TOLERANCE entity """
    DXFTYPE = 'TOLERANCE'
    DXFATTRIBS = DXFAttributes(base_class, acdb_entity, acdb_tolerance)
    MIN_DXF_VERSION_FOR_EXPORT = DXF2000

    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_tolerance)
            if len(tags):
                processor.log_unprocessed_tags(tags,
                                               subclass=acdb_tolerance.name)
        return dxf

    def export_entity(self, tagwriter: 'TagWriter') -> None:
        """ Export entity specific data as DXF tags. """
        # base class export is done by parent class
        super().export_entity(tagwriter)
        # AcDbEntity export is done by parent class
        tagwriter.write_tag2(SUBCLASS_MARKER, acdb_tolerance.name)
        self.dxf.export_dxf_attribs(
            tagwriter,
            ['dimstyle', 'insert', 'content', 'extrusion', 'x_axis_vector'])

    def transform_to_wcs(self, ucs: 'UCS') -> None:
        """ Transform LINE entity from local :class:`~ezdxf.math.UCS` coordinates to
        :ref:`WCS` coordinates.

        .. versionadded:: 0.11

        """
        self.dxf.insert = ucs.to_wcs(self.dxf.insert)
        self.dxf.x_axis_vector = ucs.direction_to_wcs(self.dxf.x_axis_vector)
        self.dxf.extrusion = ucs.direction_to_wcs(self.dxf.extrusion)
コード例 #23
0
class VPort(DXFEntity):
    """ DXF VIEW entity """
    DXFTYPE = 'VPORT'
    DXFATTRIBS = DXFAttributes(base_class, acdb_symbol_table_record,
                               acdb_vport)

    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_vport)
            if len(tags) and not processor.r12:
                processor.log_unprocessed_tags(tags, subclass=acdb_vport.name)
        return dxf

    def export_entity(self, tagwriter: 'TagWriter') -> None:
        super().export_entity(tagwriter)
        # AcDbEntity export is done by parent class
        dxfversion = tagwriter.dxfversion
        if dxfversion > DXF12:
            tagwriter.write_tag2(SUBCLASS_MARKER,
                                 acdb_symbol_table_record.name)
            tagwriter.write_tag2(SUBCLASS_MARKER, acdb_vport.name)
        self.dxf.export_dxf_attribs(tagwriter, [
            'name', 'flags', 'lower_left', 'upper_right', 'center',
            'snap_base', 'snap_spacing', 'grid_spacing', 'direction', 'target',
            'height', 'aspect_ratio', 'focal_length', 'front_clipping',
            'back_clipping', 'snap_rotation', 'view_twist', 'view_mode',
            'circle_sides', 'fast_zoom', 'ucs_icon', 'snap_on', 'grid_on',
            'snap_style', 'snap_isopair', 'plot_style_sheet', 'render_mode',
            'ucs_vp', 'ucs_origin', 'ucs_xaxis', 'ucs_yaxis', 'ucs_handle',
            'base_ucs_handle', 'ucs_ortho_type', 'elevation', 'unknown1',
            'shade_plot_setting', 'major_grid_lines', 'background_handle',
            'shade_plot_handle', 'visual_style_handle', 'default_lighting_on',
            'default_lighting_type', 'brightness', 'contrast',
            'ambient_color_aci', 'ambient_true_color', 'ambient_color_name'
        ])
コード例 #24
0
ファイル: idbuffer.py プロジェクト: Rahulghuge94/ezdxf
class IDBuffer(DXFObject):
    """DXF IDBUFFER entity"""

    DXFTYPE = "IDBUFFER"
    DXFATTRIBS = DXFAttributes(base_class, acdb_id_buffer)

    def __init__(self):
        super().__init__()
        self.handles: List[str] = []

    def _copy_data(self, entity: "DXFEntity") -> None:
        """Copy handles"""
        assert isinstance(entity, IDBuffer)
        entity.handles = list(self.handles)

    def load_dxf_attribs(self,
                         processor: SubclassProcessor = None
                         ) -> "DXFNamespace":
        dxf = super().load_dxf_attribs(processor)
        if processor:
            if len(processor.subclasses) < 2:
                raise DXFStructureError(
                    f"Missing required subclass in IDBUFFER(#{dxf.handle})")
            self.load_handles(processor.subclasses[1])
        return dxf

    def load_handles(self, tags: "Tags"):
        self.handles = [value for code, value in tags if code == 330]

    def export_entity(self, tagwriter: "TagWriter") -> None:
        """Export entity specific data as DXF tags."""
        super().export_entity(tagwriter)
        tagwriter.write_tag2(SUBCLASS_MARKER, acdb_id_buffer.name)
        self.export_handles(tagwriter)

    def export_handles(self, tagwriter: "TagWriter"):
        for handle in self.handles:
            tagwriter.write_tag2(330, handle)
コード例 #25
0
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)

    def load_dxf_attribs(self,
                         processor: SubclassProcessor = None
                         ) -> 'DXFNamespace':
        dxf = super().load_dxf_attribs(processor)
        if processor:
            if len(processor.subclasses) < 2:
                raise DXFStructureError(
                    'Missing required subclass in IDBUFFER(#{})'.format(
                        dxf.handle))
            self.load_handles(processor.subclasses[1])
        return dxf

    def load_handles(self, tags: 'Tags'):
        self.handles = [value for code, value in tags if code == 330]

    def export_entity(self, tagwriter: 'TagWriter') -> None:
        """ Export entity specific data as DXF tags. """
        # base class export is done by parent class
        super().export_entity(tagwriter)
        tagwriter.write_tag2(SUBCLASS_MARKER, acdb_id_buffer.name)
        self.export_handles(tagwriter)

    def export_handles(self, tagwriter: 'TagWriter'):
        for handle in self.handles:
            tagwriter.write_tag2(330, handle)
コード例 #26
0
class DXFLayout(PlotSettings):
    DXFTYPE = 'LAYOUT'
    DXFATTRIBS = DXFAttributes(base_class, acdb_plot_settings, acdb_layout)

    def load_dxf_attribs(self,
                         processor: SubclassProcessor = None
                         ) -> 'DXFNamespace':
        dxf = super().load_dxf_attribs(processor)
        if processor:
            processor.fast_load_dxfattribs(dxf, acdb_layout_group_codes, 2)
        return dxf

    def export_entity(self, tagwriter: 'TagWriter') -> None:
        # Set correct Model Type flag
        self.set_flag_state(1024,
                            self.dxf.name.upper() == 'MODEL',
                            'plot_layout_flags')
        super().export_entity(tagwriter)
        tagwriter.write_tag2(SUBCLASS_MARKER, acdb_layout.name)
        self.dxf.export_dxf_attribs(tagwriter, [
            'name',
            'layout_flags',
            'taborder',
            'limmin',
            'limmax',
            'insert_base',
            'extmin',
            'extmax',
            'elevation',
            'ucs_origin',
            'ucs_xaxis',
            'ucs_yaxis',
            'ucs_type',
            'block_record_handle',
            'viewport_handle',
            'ucs_handle',
            'base_ucs_handle',
        ])
コード例 #27
0
ファイル: acad_table.py プロジェクト: luoyu-123/ezdxf
class ACADTable(DXFGraphic):
    """ DXF ACAD_TABLE entity """
    DXFTYPE = 'ACAD_TABLE'
    DXFATTRIBS = DXFAttributes(base_class, acdb_entity, acdb_block_reference,
                               acdb_table)
    MIN_DXF_VERSION_FOR_EXPORT = DXF2007

    def __init__(self):
        super().__init__()
        self.data = None

    def _copy_data(self, entity: 'ACADTable') -> None:
        """ Copy data. """
        entity.data = copy.deepcopy(self.data)

    def load_dxf_attribs(self,
                         processor: SubclassProcessor = None
                         ) -> 'DXFNamespace':
        dxf = super().load_dxf_attribs(processor)
        if processor:
            processor.load_dxfattribs_into_namespace(dxf, acdb_block_reference)
            tags = processor.load_dxfattribs_into_namespace(dxf, acdb_table)
            self.load_table(tags)
        return dxf

    def load_table(self, tags: 'Tags'):
        pass

    def export_entity(self, tagwriter: 'TagWriter') -> None:
        """ Export entity specific data as DXF tags. """
        super().export_entity(tagwriter)
        tagwriter.write_tag2(SUBCLASS_MARKER, acdb_block_reference.name)
        self.dxf.export_dxf_attribs(tagwriter, ['geometry', 'insert'])
        tagwriter.write_tag2(SUBCLASS_MARKER, acdb_table.name)
        self.export_table(tagwriter)

    def export_table(self, tagwriter: 'TagWriter'):
        pass
コード例 #28
0
ファイル: image.py プロジェクト: Rahulghuge94/ezdxf
class ImageDefReactor(DXFObject):
    """DXF IMAGEDEF_REACTOR entity"""

    DXFTYPE = "IMAGEDEF_REACTOR"
    DXFATTRIBS = DXFAttributes(base_class, acdb_image_def_reactor)
    MIN_DXF_VERSION_FOR_EXPORT = DXF2000

    def load_dxf_attribs(self,
                         processor: SubclassProcessor = None
                         ) -> "DXFNamespace":
        dxf = super().load_dxf_attribs(processor)
        if processor:
            processor.fast_load_dxfattribs(dxf,
                                           acdb_image_def_reactor_group_codes,
                                           1)
        return dxf

    def export_entity(self, tagwriter: "TagWriter") -> None:
        """Export entity specific data as DXF tags."""
        super().export_entity(tagwriter)
        tagwriter.write_tag2(SUBCLASS_MARKER, acdb_image_def_reactor.name)
        tagwriter.write_tag2(90, self.dxf.class_version)
        tagwriter.write_tag2(330, self.dxf.image_handle)
コード例 #29
0
class Sun(DXFObject):
    """ DXF SUN entity """
    DXFTYPE = 'SUN'
    DXFATTRIBS = DXFAttributes(base_class, acdb_sun)
    MIN_DXF_VERSION_FOR_EXPORT = DXF2007

    def load_dxf_attribs(self,
                         processor: SubclassProcessor = None
                         ) -> 'DXFNamespace':
        dxf = super().load_dxf_attribs(processor)
        if processor:
            processor.load_dxfattribs_into_namespace(dxf, acdb_sun)
        return dxf

    def export_entity(self, tagwriter: 'TagWriter') -> None:
        """ Export entity specific data as DXF tags. """
        super().export_entity(tagwriter)
        tagwriter.write_tag2(SUBCLASS_MARKER, acdb_sun.name)
        self.dxf.export_dxf_attribs(tagwriter, [
            'version', 'status', 'color', 'true_color', 'intensity', 'shadows',
            'julian_day', 'time', 'daylight_savings_time', 'shadow_type',
            'shadow_map_size', 'shadow_softness'
        ])
コード例 #30
0
ファイル: idbuffer.py プロジェクト: luoyu-123/ezdxf
class LayerFilter(IDBuffer):
    """ DXF LAYER_FILTER entity """
    DXFTYPE = 'LAYER_FILTER'
    DXFATTRIBS = DXFAttributes(base_class, acdb_filter, acdb_layer_filter)

    def load_dxf_attribs(self,
                         processor: SubclassProcessor = None
                         ) -> 'DXFNamespace':
        dxf = super(DXFObject, self).load_dxf_attribs(processor)
        if processor:
            if len(processor.subclasses) < 3:
                raise DXFStructureError(
                    f'Missing required subclass in LAYER_FILTER(#{dxf.handle})'
                )
            self.load_handles(processor.subclasses[2])
        return dxf

    def export_entity(self, tagwriter: 'TagWriter') -> None:
        """ Export entity specific data as DXF tags. """
        super(DXFObject, self).export_entity(tagwriter)
        tagwriter.write_tag2(SUBCLASS_MARKER, acdb_filter.name)
        tagwriter.write_tag2(SUBCLASS_MARKER, acdb_layer_filter.name)
        self.export_handles(tagwriter)