Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Formatting Issue Importing RTF (Rich Text Format) into an MText entity.

16 REPLIES 16
Reply
Message 1 of 17
michellem
562 Views, 16 Replies

Formatting Issue Importing RTF (Rich Text Format) into an MText entity.

Hello;

 

I was wondering if there is any fix or workaround for this issue: When importing a RTF document into an Mtext entity, the formatting of paragraphs that are part of a list are messed up.

Here is what it should look like (screen clip from Word):

michellem_0-1717104055386.png

Here is what it imports into AutoCad:

michellem_3-1717104396367.png


If I use Lisp to tweak the Mtext codes, I can get it to look correct in AutoCad:

michellem_2-1717104188805.png

 

However, if I open the "fixed" mtext in the Mtext editor, the editor immediately turns it into the incorrect version.

 

Sincerely;

Michelle

 

16 REPLIES 16
Message 2 of 17
pendean
in reply to: michellem

@michellem You need to share actual DWG and RTF files here if you want assistance in understanding what is going on with your own files.

Message 3 of 17
michellem
in reply to: pendean

Hello Pendean;

 

Here they are. Please note the RTF is a small sample of a much larger file - enough to fill 4 sheets of 30x42 paper. The same problem occurs throughout the import of the much larger file.

 

Michelle

 

Message 4 of 17
pendean
in reply to: michellem


@michellem wrote:

...Here they are...

 


Thanks for the files: your text that is already in the DWG file was created when a test STYLE with a font definition you do not want was active, this one, and that is why you got what you got and it appears you decided to fix by the hard way by manually overriding the FONT

 

pendean_0-1717432073535.png

 

pendean_1-1717432117123.png

 

 

It appears you want to be using ARIAL NARROW for a font, yet none of your 4 text styles have that definition inside the DWG file

pendean_2-1717432240593.png

 

pendean_3-1717432264655.png

 

pendean_4-1717432287593.png

 

 

So first, in the DWG file, you must have a text STYLE defined with that FONT, then sure it is active BEFORE you start MTEXT and import any text

pendean_5-1717432417724.png

 

pendean_8-1717432572411.png

 

pendean_7-1717432550736.png

 

 

pendean_6-1717432530702.png

 

You always want to preset your TEXTSIZE setting too in the DWG file.

 

IF... settings in AutoCAD do not really matter to you or any of your colleagues/file recipients, and you only wish to duplicate the content in the RTF file all the time the easy way, then you want to COPY/PASTE from inside your RTF file (MSWORD) to inside the open MTEXT window inside your DWG file.

Message 5 of 17
michellem
in reply to: pendean

I'm sorry but the font is not the issue I was concerned about. Since we use an SHX in cad and Word does not support SHX fonts, we always have to fix up the font upon text import. For the files I submitted, I left out the font fixup that we always do.

 

The issue I have is that the list formatting does not import correctly.

 

From the RTS file, note the clouded items:

michellem_0-1717437349620.png

This is how it imports into AutoCad:

michellem_1-1717437453209.png

It does not matter if I cut/paste the text or use the import text command: the result is the same misalignment.

 

Since we have to, by executive decision, to import portions of text from the same RTS file for every project we do, it is getting real old, real fast, to have to manually fix up the text each and every time.

 

Michelle

 

 

Message 6 of 17
pendean
in reply to: michellem


@michellem wrote:

...

michellem_0-1717437349620.png

This is how it imports into AutoCad:

michellem_1-1717437453209.png

 


You'll need to fix these manually on your own inside AutoCAD: MTEXT is a very limited text editor.

 

pendean_1-1717439307670.png

 

pendean_2-1717439393959.png

 

pendean_0-1717439193220.png

 

pendean_4-1717439474091.png

 

pendean_5-1717439679931.png

 


@michellem wrote:

...Since we use an SHX in cad and Word does not support SHX fonts, we always have to fix up the font upon text import. For the files I submitted, I left out the font fixup that we always do.


You are going to have fun reconciling those two very different text object formatting all the time. no fix.

And yes, MSWORD can...

 

pendean_6-1717439809157.png

 

pendean_7-1717439856275.png

 

 

 

 

 

 

Message 7 of 17
Jason.Piercey
in reply to: michellem

I've found the width of the mtext entity is critical when trying to get the bulleting to line up properly. Another thing I've noticed is that after I import the RTF I need to scale the entire block of mtext rather than change the text height to keep the formatting from doing strange things.

 

 

Message 8 of 17
Jason.Piercey
in reply to: michellem

Snapshot of my RTF imported notes

 

JasonPiercey_0-1717441018813.png

 

Message 9 of 17
michellem
in reply to: Jason.Piercey

Hello Jason;

 

Hmm...So what guidelines should I try on the width setting of Mtext entity?

 

Michelle

 

Message 10 of 17
Jason.Piercey
in reply to: michellem

Keep in mind that AutoCAD is not a word processor and editing/formatting large blocks of notes just sucks.

 

The way I have my RTF file setup (I actually use a DOCX as the main source file then save as an RTF) is each indentation level is setup as a style in Microsoft Word. After I import into AutoCAD (in paper space), and scale the text to get the desired plotted text height, I've found a 7" width works best for my general notes. You may have to also adjust paragraph/gutter spacing if you are using columns in your mtext.

 

They never import perfectly but the few spots that don't align correctly I can usually just tab them over after importing. I've found this method far easier than trying to get AutoCAD to do anything sensible.

Message 11 of 17
Jason.Piercey
in reply to: michellem

You can see here that things to not always align properly after importing. Now this particular spot isn't setup as a style for indentation but rather has been tabbed to make a "table format". It is these instances that I can usually correct simply by tabbing over a space. The rest of the main indentation levels align properly.

 

JasonPiercey_0-1717442693407.png

 

Message 12 of 17
michellem
in reply to: pendean

Hello Pendean;

 

What version of Autocad are you using?

 

When I select just the "i", "ii" etc paragraphs (and no other paragraphs) and then adjust the two margin settings you indicated, the Mtext editor moves the margin settings for the "a", "b" and "c" along with the selected paragraphs.

 

I am beginning to think Autocad changed the rules by which the MText editor operates. I seem to dimly recall that the procedure you suggested used to work. However, I have not done a lot of Autocad projects for the last couple of years (Revit projects instead) and now that I am getting more Autocad projects, I have a newer version of Autocad.

 

I'll see if anyone has an older version of Autocad to test it on.


For SHX fonts, our standard font "Acads.shx" does not appear in the font list when using Word. I also seem to recall reading something 10 or 15 years ago, that Autocad started including TTF font equivalents for their standard out-of-box fonts...which ours is not.

 

Message 13 of 17
pendean
in reply to: michellem


@michellem wrote:

....What version of Autocad are you using?...


AutoCAD 2024, but that makes no difference at all, manual editing in MTEXT is vintage-1980s era word processor editing: forget everything you know and use in MSWORD, that does not work here. See attached.

 

You folks need a new plan to meet the top-dog's edicts: perhaps a purchased add-on can be considered, here is one of many

https://www.dotsoft.com/word2cad.htm 

 

Message 14 of 17
michellem
in reply to: pendean

Hmm...I downloaded the file you sent.

 

Here is the image of the text before any editing:

michellem_0-1717448069781.png


As soon as I open the text in the text editor, this is what happens:

michellem_1-1717448156841.png

 

Does this not happen to you in Autocad 2024?

 

Michelle

 




Message 15 of 17
pendean
in reply to: michellem


@michellem wrote:

...Does this not happen to you in Autocad 2024?


No, sorry. Welcome to MTEXT formatting in AutoCAD

pendean_0-1717448985420.png

 

 

 

 

Message 16 of 17
michellem
in reply to: pendean

Tried full version Autocad 2020 and full version Autocad 2025 - no joy. Would you happen to be using the Mac version? We are Windows 10.

 

Michelle

Message 17 of 17
michellem
in reply to: michellem

Hello;

 

An update on this issue. After poking around for about 3 hrs, I think I understand what the MText editor's rules are in this case.

 

When importing text from a RTF file (or copy/pasting text) into an MText entity, the MText editor will inspect the incoming text to see what paragraphs should be treated as a list. That is, if the "Allow Bullets And Lists" option is turned on. A paragraph will be considered a list if the characters at the beginning of the paragraph fit a certain pattern outlined below. It does not appear to matter if the source RTF considers the paragraph part of a list or not.
 
The MText editor has four types of lists: Bulleted, Numbered, Uppercase Letters, and Lowercase letters. A bulleted list is unordered and can use any character or set of characters shown below as the "bullet". The other list types are ordered (eg 1, 2, 3, etc) but the editor does not enforce any ordering upon import. For example, a list like 2, 6, 4 is perfectly fine. One interesting side effect of this is that one could import a paragraph like "6. This is a numbered list." and the MText editor would create a numbered list that starts at six. The next paragraph entered by the user would then be seven.
 
For numbered lists, the MText editor looks for a paragraph that starts with a pattern like this -  <number><list marker><space or tab>. <number> can be an integer or a real. <list marker>'s are one of these characters: " . ) > } "
 
For alphabetical lists, the MText editor looks for a paragraph that starts with a pattern like this - <letter><list marker><space or tab>. <letter> can one or more of either Uppercase letters or Lowercase letters but not a mix of both. <letter> can be a number. At least for me in Seattle, only letters belonging to the Latin group of a Unicode font are eligible.
 
For bulleted lists, the MText editor looks for a paragraph that starts with a pattern like this - <special character><space or tab>. The <special character> can be character belonging to one of these Unicode groups:
Symbols & Dingbats
Miscellaneous Technical
Mathematical Operators
Arrows
Number Forms (excluding 0 to 9)
Letterlike Symbols
Currency
General Punctuation
 
The above list should not be considered totally complete - there may be other groups. Charmap is a good tool to see which character is in which grouping.
 
Note, that the above assumes True Type fonts and not SHX fonts. 
 
Another peculiarity of the MText editor, is that all numbered or alphabetical lists in an Mtext entity can only have one left margin/indent position. For example this is not possible:
1. Outer level Text
     1. Inner level Text
 
The MText editor will force the above to be:
1. Outer level Text
1. Inner level Text
 
The above is also true for Bulleted lists except that a given <special character> can only have one indent.
 
So for my case, the MText editor determined that the "roman numerals" were  a lowercase letter list and so aligned it with the previous lowercase letter list.
 
Michelle
 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report