How to use the ezdxf.lldxf.const.DXFStructureError function in ezdxf

To help you get started, we’ve selected a few ezdxf examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mozman / ezdxf / ezdxf / modern / material.py View on Github external
def _get_matrix(self, code: int) -> 'Matrix44':
        subclass = self.tags.subclasses[1]  # always 2nd subclass
        try:
            return matrix_accessors.get_matrix(subclass, code)
        except DXFStructureError:
            raise DXFStructureError('Invalid transformation matrix in entity ' + self.__str__())
github mozman / ezdxf / src / ezdxf / entities / acis.py View on Github external
def load_matrix(subclass: 'Tags', code: int) -> Matrix44:
    values = [tag.value for tag in subclass.find_all(code)]
    if len(values) != 16:
        raise DXFStructureError('Invalid transformation matrix.')
    return Matrix44(values)
github mozman / ezdxf / ezdxf / lldxf / attributes.py View on Github external
def _get_extended_type(self, tags: Tags) -> Tuple[float, ...]:
        value = tags.get_first_value(self.code)
        if len(value) == 3:
            if self.xtype is XType.point2d:
                raise DXFStructureError("expected 2D point but found 3D point")
        elif self.xtype is XType.point3d:  # len(value) == 2
            raise DXFStructureError("expected 3D point but found 2D point")
        return value
github mozman / ezdxf / src / ezdxf / layouts / base.py View on Github external
def add_entity(self, entity: 'DXFGraphic') -> None:
        """
        Add an existing :class:`DXFGraphic` entity to a layout, but be sure to unlink (:meth:`~BaseLayout.unlink_entity`)
        entity from the previous owner layout. Adding entities from a different DXF drawing is not supported.

        """
        if entity.doc != self.doc:
            raise DXFStructureError('Adding entities from a different DXF drawing is not supported.')

        self.block_record.add_entity(entity)
github mozman / ezdxf / ezdxf / sections / classes.py View on Github external
def _build(self, entities: Iterator[DXFTag]) -> None:
        section_head = next(entities)
        if section_head[0] != (0, 'SECTION') or section_head[1] != (2, 'CLASSES'):
            raise DXFStructureError("Critical structure error in CLASSES section.")

        for class_tags in entities:
            self.register(ExtendedTags(class_tags))
github mozman / ezdxf / src / ezdxf / addons / iterdxf.py View on Github external
def __init__(self, name: Filename):
        self.structure, self.sections = self._load_index(name)
        self.file: BinaryIO = open(name, mode='rb')
        if 'ENTITIES' not in self.sections:
            raise DXFStructureError('ENTITIES section not found.')
        if self.structure.version > 'AC1009' and 'OBJECTS' not in self.sections:
            raise DXFStructureError('OBJECTS section not found.')
github mozman / ezdxf / src / ezdxf / sections / classes.py View on Github external
def load(self, entities: Iterator[DXFEntity]) -> None:
        section_head = next(entities)  # type: DXFTagStorage

        if section_head.dxftype() != 'SECTION' or section_head.base_class[1] != (2, 'CLASSES'):
            raise DXFStructureError("Critical structure error in CLASSES section.")

        for cls_entity in entities:
            self.register(cast(DXFClass, cls_entity))
github mozman / ezdxf / ezdxf / sections / sections.py View on Github external
def __getattr__(self, key):
        try:
            return self._sections[Sections.key(key)]
        except KeyError:  # internal exception
            # DXFStructureError because a requested section is not present, maybe a typo, but usual a hint for an
            # invalid DXF file.
            raise DXFStructureError('{} section not found'.format(key.upper()))
github mozman / ezdxf / ezdxf / lldxf / attributes.py View on Github external
def _get_extended_type(self, tags: Tags) -> Tuple[float, ...]:
        value = tags.get_first_value(self.code)
        if len(value) == 3:
            if self.xtype is XType.point2d:
                raise DXFStructureError("expected 2D point but found 3D point")
        elif self.xtype is XType.point3d:  # len(value) == 2
            raise DXFStructureError("expected 3D point but found 2D point")
        return value