Пример #1
0
 def _set_path_tags(self, vertices):
     boundary = [DXFVertex(14, value) for value in vertices]
     subclasstags = Tags(tag for tag in self.tags.subclasses[2]
                         if tag.code != 14)
     subclasstags.extend(boundary)
     self.tags.subclasses[2] = subclasstags
     self.dxf.count_boundary_points = len(vertices)
Пример #2
0
 def acad_mtext_columns_xdata(self) -> Tags:
     tags = Tags([
         DXFTag(1000, "ACAD_MTEXT_COLUMNS_BEGIN"),
         DXFTag(1070, 47), DXFTag(1070, self.count),  # incl. main MTEXT
     ])
     tags.extend(  # writes only (count - 1) handles!
         DXFTag(1005, handle) for handle in self.mtext_handles())
     tags.append(DXFTag(1000, "ACAD_MTEXT_COLUMNS_END"))
     return tags
Пример #3
0
 def acad_mtext_column_info_xdata(self) -> Tags:
     tags = Tags([
         DXFTag(1000, "ACAD_MTEXT_COLUMN_INFO_BEGIN"),
         DXFTag(1070, 75), DXFTag(1070, int(self.column_type)),
         DXFTag(1070, 79), DXFTag(1070, int(self.auto_height)),
         DXFTag(1070, 76), DXFTag(1070, self.count),
         DXFTag(1070, 78), DXFTag(1070, int(self.reversed_column_flow)),
         DXFTag(1070, 48), DXFTag(1040, self.width),
         DXFTag(1070, 49), DXFTag(1040, self.gutter_width),
     ])
     if self.has_dynamic_manual_height:
         tags.extend([DXFTag(1070, 50), DXFTag(1070, len(self.heights))])
         tags.extend(DXFTag(1040, height) for height in self.heights)
     tags.append(DXFTag(1000, "ACAD_MTEXT_COLUMN_INFO_END"))
     return tags
Пример #4
0
    def _setup_complex_pattern(self, pattern: str, length: float) -> Tags:
        tokens = lin_compiler(pattern)
        tags = Tags([
            DXFTag(72, 65),  # letter 'A'
        ])

        tags2 = [DXFTag(73, 0), DXFTag(40, length)]  # temp length of 0
        count = 0
        for token in tokens:
            if isinstance(token, DXFTag):
                if tags2[-1].code == 49:  # useless 74 only after 49 :))
                    tags2.append(DXFTag(74, 0))
                tags2.append(token)
                count += 1
            else:  # TEXT or SHAPE
                tags2.extend(cast(
                    'ComplexLineTypePart', token).complex_ltype_tags(self.doc))
        tags2.append(DXFTag(74, 0))  # useless 74 at the end :))
        tags2[0] = DXFTag(73, count)
        tags.extend(tags2)
        return tags
Пример #5
0
 def _set_path_tags(self, vertices):
     boundary = [DXFVertex(11, value) for value in vertices]
     subclasstags = Tags(tag for tag in self.tags.subclasses[2] if tag.code != 11)  # filter out existing path tags
     subclasstags.extend(boundary)
     self.tags.subclasses[2] = subclasstags
Пример #6
0
class XRecord(DXFObject):
    """DXF XRECORD entity"""

    DXFTYPE = "XRECORD"
    DXFATTRIBS = DXFAttributes(base_class, acdb_xrecord)

    def __init__(self):
        super().__init__()
        self.tags = Tags()

    def _copy_data(self, entity: DXFEntity) -> None:
        assert isinstance(entity, XRecord)
        entity.tags = Tags(self.tags)

    def load_dxf_attribs(
        self, processor: SubclassProcessor = None
    ) -> "DXFNamespace":
        dxf = super().load_dxf_attribs(processor)
        if processor:
            try:
                tags = processor.subclasses[1]
            except IndexError:
                raise DXFStructureError(
                    f"Missing subclass AcDbXrecord in XRecord (#{dxf.handle})"
                )
            start_index = 1
            if len(tags) > 1:
                # First tag is group code 280, but not for DXF R13/R14.
                # SUT: doc may be None, but then doc also can not
                # be R13/R14 - ezdxf does not create R13/R14
                if self.doc is None or self.doc.dxfversion >= DXF2000:
                    code, value = tags[1]
                    if code == 280:
                        dxf.cloning = value
                        start_index = 2
                    else:  # just log recoverable error
                        logger.info(
                            f"XRecord (#{dxf.handle}): expected group code 280 "
                            f"as first tag in AcDbXrecord"
                        )
            self.tags = Tags(tags[start_index:])
        return dxf

    def export_entity(self, tagwriter: "TagWriter") -> None:
        super().export_entity(tagwriter)
        tagwriter.write_tag2(SUBCLASS_MARKER, acdb_xrecord.name)
        tagwriter.write_tag2(280, self.dxf.cloning)
        tagwriter.write_tags(Tags(totags(self.tags)))

    def reset(self, tags: Iterable[Union[DXFTag, Tuple[int, Any]]]) -> None:
        """Reset DXF tags. """
        self.tags.clear()
        self.tags.extend(totags(tags))

    def extend(self, tags: Iterable[Union[DXFTag, Tuple[int, Any]]]) -> None:
        """Extend DXF tags. """
        self.tags.extend(totags(tags))

    def clear(self) -> None:
        """Remove all DXF tags. """
        self.tags.clear()