MText or DBText, which one to use?

MText or DBText, which one to use?

Anonymous
Not applicable
2,603 Views
4 Replies
Message 1 of 5

MText or DBText, which one to use?

Anonymous
Not applicable

Hello all,

 

I am trying to label closed polylines on the canvas with text labels using the .net api. I am presented with these two options. MText and DBText What are differences between the two? Is there any particular advantages/disadvantages using one over the other?

 

I have already tried online searches for these but the search results where not very helpful. Any ideas would greatly be appreciated.

 

Thanks a lot in advance.

 

Sincerely,

 

Rashid.

0 Likes
2,604 Views
4 Replies
Replies (4)
Message 2 of 5

Kent1Cooper
Consultant
Consultant

If by "DBText" [is that a .net API term?] you mean what a lot of people often refer to as "DTEXT," be aware that in AutoCAD there is no such entity type -- it's just TEXT.

 

If any of your labels will need more than one line, Mtext will do that in one object [that's what the M is for], whereas with Text you would need a separate object for each line.

 

For single-line content, Text uses less memory than Mtext.

 

If you would ever need to include stacked fractions, Text can't do that [unless you have a font with special characters defined for some of those], so you would need to use Mtext.

 

Text can be given a width factor and/or an obliquing angle, neither of which you can do with Mtext except for the limited obliquing of italics, but a) that can only be used with .ttf fonts [not .shx fonts -- Text can oblique either], and b) you have no say in the degree of obliquing [with Text, you can tilt it to any angle you want].

 

Mtext can be made Bold or not within the use of the same [.ttf only] font, whereas Text [of whichever font type] requires either a bolder font or [in .shx fonts] a different lineweight.

 

With Mtext, you can change properties of portions of the same object separately from the rest [height, italics, bold, color, even the font], whereas all those characteristics [and also width factor] apply to the entirety of a Text object.  So with Mtext, you can [for instance] have a room label in a floor plan that has the room name larger and bolder, and its square footage smaller and lighter, and its occupant's name different from either of those [and italic, or whatever], and a room number, and so on, all in one object.

 

Text has both Middle and Middle Center justification options, as well as Left and Bottom Left, Center and Bottom Center, and Right and Bottom Right, which have different effects depending on whether the content has characters that extend [for the Middle versions} above or below the nominal height, or [for the Bottom versions] below the baseline.  Mtext has only the two-word versions of all those, so [for instance] you can't have the insertion-point bottom of an Mtext object on the baseline of the bottom line of text if it has any descenders, and if you change its content, it can shift position without its insertion point having been moved.

 

Text also has the Align and Fit options that have no corollary at all in Mtext.

 

Mtext has a certain amount of word-processing-like capability [e.g. tabs].

 

There are probably a few other things....

Kent Cooper, AIA
Message 3 of 5

Kent1Cooper
Consultant
Consultant

@Kent1Cooper wrote:

....

Text can be given a width factor and/or an obliquing angle, neither of which you can do with Mtext ....


I find that newer versions do have those available in Mtext [by selection within the content, not applicable overall to Mtext objects as overrides but only if part of the definition of their text Style], so that's a version-dependent difference.

Kent Cooper, AIA
0 Likes
Message 4 of 5

Anonymous
Not applicable

Thanks a lot for your reply. It cleared up quite a few issues. I appreciate it very much.

0 Likes
Message 5 of 5

fieldguy
Advisor
Advisor

Mr. Lisp?  Is that you?  I have read several of your posts over the years and I am taking this opportunity to say Thanks!  Are you working with OOP and Autodesk products?  If not, IMO you should try it - I am willing to bet you'll enjoy it and do quite well. There are plenty of samples and good answers in this forum.

 

>>If by "DBText" [is that a .net API term?]<<  The .NET autodesk libraries are built with namespaces inside assemblies.  The assembly "Acdbmgd.dll" (aka managed autocad database reference) contains the "Autodesk.AutoCAD.DatabaseServices" namespace which contains autocad "Entity" class definitions.  There are 2 options for text - dbtext and mtext.  When you create an instance of the class (c# eg.  "MText mymtext = new MText();") you have access to all mtext methods and properties as defined in the library.  The screen shots are from the Object Browser in Visual Studio.  

 

acdbmgd_dbtext.PNG

acdbmgd_mtext.PNG

  

 

 

0 Likes