How to use the ezdxf.lldxf.tags.Tags 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 / tests / test_01_dxf_entities / test_101_dxfnamespace.py View on Github external
def test_load_doublettes():
    from ezdxf.lldxf.attributes import DefSubclass, DXFAttr
    from ezdxf.lldxf.tags import Tags, DXFTag
    subclass = DefSubclass('AcDbTest', {
        'test1': DXFAttr(1),
        'test2': DXFAttr(2),
        'test3': DXFAttr(1),  # same group code for different attribute
    })

    class TestEntity(DXFEntity):
        DXFATTRIBS = DXFAttributes(subclass)

    data = Tags([
        DXFTag(1, '1'),
        DXFTag(2, '2'),
        DXFTag(1, '3'),
    ])
    ns = DXFNamespace(entity=TestEntity())
    SubclassProcessor.load_tags_into_namespace(ns, data, subclass)
    assert ns.test1 == '1'
    assert ns.test2 == '2'
    assert ns.test3 == '3'
github mozman / ezdxf / src / ezdxf / pp / dxfpp.py View on Github external
def entity2html(self, tags: Tags, create_ref_links=False, show_ref_status=False):
        """DXF entity as <div> container.
        """
        tags = Tags(tags)
        name = tags.dxftype()
        if create_ref_links:  # use entity name as link to the DXF reference
            name = build_ref_link_button(name)
        refs = ""
        if show_ref_status:
            try:
                handle = tags.get_handle()
            except DXFValueError:
                pass
            else:
                if handle not in self.pointers:
                    refs = '<div class="ref-no">[unreferenced]</div>'
                else:
                    refs = self.pointers2html(self.pointers[handle])
        return ENTITY_TPL.format(name=name, tags=self.tags2html(tags), references=refs)
</div>
github mozman / ezdxf / src / ezdxf / entities / dxfentity.py View on Github external
def get_xdata(self, appid: str) -> Tags:
        """ Returns extended data for `appid`.

        Args:
            appid: application name as defined in the APPID table.

        Raises:
            DXFValueError: no extended data for `appid` found

        """
        if self.xdata:
            return Tags(self.xdata.get(appid)[1:])
        else:
            raise DXFValueError(appid)
github mozman / ezdxf / src / ezdxf / entities / viewport.py View on Github external
DXFTag(1040, dxf.snap_angle),
            DXFTag(1040, dxf.snap_base_point[0]),
            DXFTag(1040, dxf.snap_base_point[1]),
            DXFTag(1040, dxf.snap_spacing[0]),
            DXFTag(1040, dxf.snap_spacing[1]),
            DXFTag(1040, dxf.grid_spacing[0]),
            DXFTag(1040, dxf.grid_spacing[1]),
            DXFTag(1070, flag(const.VSF_HIDE_PLOT_MODE)),
            DXFTag(1002, '{'),  # start frozen layer list
        ]
        tags.extend(DXFTag(1003, layer_name) for layer_name in self.frozen_layers)
        tags.extend([
            DXFTag(1002, '}'),  # end of frozen layer list
            DXFTag(1002, '}'),  # MVIEW
        ])
        return Tags(tags)
github mozman / ezdxf / src / ezdxf / entities / xdata.py View on Github external
def add(self, appid: str, tags: Iterable) -> None:
        data = Tags(dxftag(code, value) for code, value in tags)
        if data[0] != (XDATA_MARKER, appid):
            data.insert(0, dxftag(XDATA_MARKER, appid))
        self._add(data)
github mozman / ezdxf / src / ezdxf / sections / acdsdata.py View on Github external
def _write_header(self, tagwriter: 'TagWriter') -> None:
        tagwriter.write_tags(Tags([self._dxftype, self.flags]))
github mozman / ezdxf / ezdxf / modern / image.py View on Github external
def _set_path_tags(self, vertices: Sequence[Tuple[float, float]]):
        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)
github mozman / ezdxf / ezdxf / lldxf / extendedtags.py View on Github external
def collect_app_data(starttag: DXFTag) -> None:
            """
            AppData can't contain XDATA or subclasses.

            I guess AppData can only appear in the first subclass (unnamed)

            """
            data = Tags([starttag])
            closing_strings = ('}', starttag.value[1:] + '}')  # alternative closing tag 'APPID}'
            while True:
                try:
                    tag = next(tagstream)
                except StopIteration:
                    raise DXFStructureError("Missing closing (102, '}') tag for appdata structure.")
                data.append(tag)
                if (tag.code == APP_DATA_MARKER) and (tag.value in closing_strings):
                    break
                    # every other (102, ) tag is treated as usual tag
            self.appdata.append(data)
github mozman / ezdxf / src / ezdxf / entities / dxfentity.py View on Github external
Returns:
             Tags: unprocessed tags

        """

        # r12 has always unprocessed tags, because there are all tags in one subclass and one subclass definition never
        # covers all tags e.g. handle is processed in main_call, so it is an unprocessed tag in AcDbEntity.
        if self.r12:
            tags = self.subclasses[0]
        else:
            if index is None:
                tags = self.find_subclass(subclass_definition.name)
            else:
                tags = self.subclass_by_index(index)
            if tags is None:
                return Tags()
        return self.load_tags_into_namespace(dxf, tags[1:], subclass_definition)