コード例 #1
0
ファイル: mtext.py プロジェクト: Rahulghuge94/ezdxf
def extract_mtext_text_frame_handles(xdata: XData) -> List[str]:
    # Stores information about the text frame until DXF R2018.
    # Newer CAD applications do not need that information nor the separated
    # LWPOLYLINE as text frame entity.
    handles: List[str] = []
    if "ACAD" in xdata:
        acad = xdata.get("ACAD")
    else:
        return handles

    try:
        start, end = find_begin_and_end_of_encoded_xdata_tags(
            "ACAD_MTEXT_TEXT_BORDERS", acad)
    except NotFoundException:
        return handles

    for code, value in acad[start:end]:
        # multiple handles to a LWPOLYLINE entity could be present:
        if code == 1005:
            handles.append(value)

    # remove MTEXT_TEXT_BORDERS data
    del acad[start:end]
    if len(acad) < 2:
        xdata.discard("ACAD")
    return handles
コード例 #2
0
ファイル: mtext.py プロジェクト: yanbin-ha/ezdxf
def load_mtext_linked_column_handles(tags: Tags) -> List[str]:
    handles = []
    try:
        start, end = find_begin_and_end_of_encoded_xdata_tags(
            "ACAD_MTEXT_COLUMNS", tags)
    except NotFoundException:
        return handles
    for code, value in tags[start:end]:
        if code == 1005:
            handles.append(value)
    return handles
コード例 #3
0
ファイル: mtext.py プロジェクト: Rahulghuge94/ezdxf
def load_mtext_column_info(tags: Tags) -> Optional[MTextColumns]:
    try:  # has column info?
        start, end = find_begin_and_end_of_encoded_xdata_tags(
            "ACAD_MTEXT_COLUMN_INFO", tags)
    except NotFoundException:
        return None
    columns = MTextColumns()
    height_count = 0
    group_code = None
    for code, value in tags[start + 1:end]:
        if height_count:
            if code == 1040:
                columns.heights.append(value)
                height_count -= 1
                continue
            else:  # error
                logger.error("missing column heights in MTEXT entity")
                height_count = 0

        if group_code is None:
            group_code = value
            continue

        if group_code == 75:
            columns.column_type = ColumnType(value)
        elif group_code == 79:
            columns.auto_height = bool(value)
        elif group_code == 76:
            # column count, may not match the count of linked MTEXT entities!
            columns.count = int(value)
        elif group_code == 78:
            columns.reversed_column_flow = bool(value)
        elif group_code == 48:
            columns.width = value
        elif group_code == 49:
            columns.gutter_width = value
        elif group_code == 50:
            height_count = int(value)
        group_code = None
    return columns
コード例 #4
0
ファイル: mtext.py プロジェクト: yanbin-ha/ezdxf
def load_mtext_defined_height(tags: Tags) -> float:
    # The defined height stored in the linked MTEXT entities, is not required:
    #
    # If all columns have the same height (static & dynamic auto height), the
    # "defined_height" is stored in the main MTEXT, but the linked MTEXT entities
    # also have a "ACAD_MTEXT_DEFINED_HEIGHT" group in the ACAD section of XDATA.
    #
    # If the columns have different heights (dynamic manual height), these
    # height values are only stored in the main MTEXT. The linked MTEXT
    # entities do not have an ACAD section at all.

    height = 0.0
    try:
        start, end = find_begin_and_end_of_encoded_xdata_tags(
            "ACAD_MTEXT_DEFINED_HEIGHT", tags)
    except NotFoundException:
        return height

    for code, value in tags[start:end]:
        if code == 1040:
            height = value
    return height
コード例 #5
0
ファイル: test_105_xdata.py プロジェクト: Rahulghuge94/ezdxf
 def test_raise_exception_without_begin_tag(self):
     with pytest.raises(DXFStructureError):
         find_begin_and_end_of_encoded_xdata_tags(
             "ACAD_MTEXT_COLUMN_INFO", Tags.from_text(WITHOUT_BEGIN_TAG))
コード例 #6
0
ファイル: test_105_xdata.py プロジェクト: Rahulghuge94/ezdxf
 def test_raise_exception_if_not_found(self):
     with pytest.raises(NotFoundException):
         find_begin_and_end_of_encoded_xdata_tags(
             "MOZMAN", Tags.from_text(COLUMNS_SPEC))
コード例 #7
0
ファイル: test_105_xdata.py プロジェクト: Rahulghuge94/ezdxf
 def test_find_begin_and_end_of_column_info(self):
     start, end = find_begin_and_end_of_encoded_xdata_tags(
         "ACAD_MTEXT_COLUMN_INFO", Tags.from_text(COLUMNS_SPEC))
     assert start, end == (1, 3)