Get Content From DXF Entities

TEXT Entity

The content of the TEXT entity is stored in a single DXF attribute Text.dxf.text and has an empty string as default value:

for text in msp.query("TEXT"):
    print(text.dxf.text)

The plain_text() method returns the content of the TEXT entity without formatting codes.

See also

Classes

Tutorials

MTEXT Entity

The content of the MTEXT entity is stored in multiple DXF attributes. The content can be accessed by the read/write property text and the DXF attribute MText.dxf.text and has an empty string as default value:

for mtext in msp.query("MTEXT"):
    print(mtext.text)
    # is the same as:
    print(mtext.dxf.text)

Important

The line ending character \n will be replaced automatically by the MTEXT line ending \P.

The plain_text() method returns the content of the MTEXT entity without inline formatting codes.

MLEADER Entity

The content of MLEADER entities is stored in the MultiLeader.context object. The MLEADER contains text content if the context.mtext attribute is not None and block content if the context.block attribute is not None

Text Content

for mleader in msp.query("MLEADER MULTILEADER"):
    mtext = mleader.context.mtext
    if mtext:
        print(mtext.insert)  # insert location
        print(mtext.default_content)  # text content

The text content supports the same formatting features as the MTEXT entity.

Block Content

The INSERT (block reference) attributes are stored in MultiLeader.context.block as BlockData.

for mleader in msp.query("MLEADER MULTILEADER"):
    block = mleader.context.block
    if block:
        print(block.insert)  # insert location

The ATTRIB attributes are stored outside the context object in MultiLeader.block_attribs as AttribData.

for mleader in msp.query("MLEADER MULTILEADER"):
    for attrib in mleader.block_attribs:
        print(attrib.text)  # text content of the ATTRIB entity

DIMENSION Entity

TODO

ACAD_TABLE Entity

TODO

INSERT Entity - Block References

TODO

Get Attribute Content

TODO

Get Virtual Entities

TODO