Skip to content

MText support #238

@ChrisClems

Description

@ChrisClems

MText import and export is currently broken under netDXF. In an AutoCAD MText entity, the line break is represented by \P. In ImportDXF.cs, the MText value is being retrieved with the PlainText() method which strips the special characters specific to MText style overrides and replaces \P with a standard \r\n line termination.

In ExportDXF.cs, Text GeoObjects are being exported with the line termination intact, creating an invalid DXF. In the below attached example, the text entity will look like this:

AcDbText
1
100932
-02
10
0.1587455459

Where -02 is the second line of the text string but is being interpreted as an invalid group code, causing AutoCAD to fail to open the file.

I have a PR to replace newlines with spaces during export. There's not really a great universal fix to this without a much larger change to somehow support exporting MText entities. I can't think of a good solution off the top of my head. Import could be handled by arranging a list of text objects based on the text height and upward vector of the text which I've done in previous CAD plugins, but I don't know how to maintain their association for export without multi-line support in the Text GeoObject.

Another option is to preserve the newlines on import as-is, then export conditionally as MText when a newline character is found, replacing it with \P, however the interim Text GeoObject will still have no support for the newline while within CADAbility.

100932-02.psm.dxf.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions