We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Convert text with formatting to plain text

When encountering mtext entities that contain formatting codes like this example:
FLANGE 300# {\C256;RFWN 0.218"" WT} A694 F52
On screen it looks like: FLANGE 300# RFWN 0.218" WT A694 F52

AutoDesk does have the ExplodeFragments function to explode the mtext into regular text with no formatting with this code:

       ' explode the text
                                                Using mt = New MText()
                                                    mt.Contents = strCell

                                                    ' Explode the text fragments
                                                    mt.ExplodeFragments(Function(a, b)
                                                                            If a IsNot Nothing Then
                                                                                ' Assuming we have a fragment, use its text
                                                                                ' to set the cell contents
                                                                                strCell = a.Text
                                                                            End If
                                                                            Return MTextFragmentCallbackStatus.Continue
                                                                        End Function)
                                                End Using 

However, this does have a bug, in which if you were to use that code, all you would wind up with is:
A694 F52
Which the text is incomplete and worthless.

Autodesk has suggested to create an elaborate regex pattering from the code lists on the following pages:

However that is beyond my capabilities.
Does Aspose.CAD offer a function to accomplish converting mtext string with formatting to regular text?

Could you please try cadMText.FullClearText (https://reference.aspose.com/cad/net/aspose.cad.fileformats.cad.cadobjects/cadmtext/fullcleartext/), is it helpful?

Can I pass the formatted string directly to this to get the cleaned text?.
Or do I need to open the DWG and get the object’s property?

this is the property of the specific MText object in the drawing. You need to load the DWG and call this property for the required MText entity.