831 Posts
7 Kudos
Registered: ‎06-08-2007
Post 1 of 3

change font in mtext

526 Views, 2 Replies
01-24-2012 11:21 AM

i have 26000 mtext that has overridden font inside the property. set to bold and print out look like crap.


see attached i want all the text to look like the text on the left. right is what they look like now. i just copied a few as an example.


can't find the font property in the mtext object:


PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesButton1.Click


Dim doc AsDocument = Application.DocumentManager.MdiActiveDocument


Dim db AsDatabase = doc.Database


'Dim id As ObjectIdDim ed AsEditor = doc.Editor


Dim oBlock As BlockReference = NothingDim tv() As TypedValue = {NewTypedValue(DxfCode.Start, TextBox1.Text)}


', New TypedValue(DxfCode.LayerName, "Layer1")}Dim selFilter AsNewSelectionFilter(tv)


Dim ss AsSelectionSet = ed.SelectAll(selFilter).Value


Using trans AsTransaction = db.TransactionManager.StartTransaction()


TryDim bt AsBlockTable = trans.GetObject(db.BlockTableId, OpenMode.ForWrite)


ForEach selObj As SelectedObject Inss


'trans.GetObject(selObj.ObjectId, OpenMode.ForWrite).Erase()Dim oText As MText = CType(trans.GetObject(selObj.ObjectId, OpenMode.ForWrite), MText)




Catch'ex As Exception' MsgBox("Error: " + ex.Message)EndTryEndUsingEndSub

Civil 3D 2014
Work: i7 4770, SSD, 16GB, K2000, Dell PH2414H
Home: i7 3930k, SSD, 16GB, GTX 590, U3011
*Expert Elite*
753 Posts
54 Kudos
Registered: ‎02-13-2008
Post 2 of 3

Re: change font in mtext

01-24-2012 12:50 PM in reply to: wang890

The font is specified (or overridden) in the Content of the Mtext.  In your example drawing you will see that the beginning of the Content is "\Fbold.shx;"

Dave O.                                                                  Sig-Logos32.png
192 Posts
26 Kudos
Registered: ‎08-17-2007
Post 3 of 3

Re: change font in mtext

01-24-2012 12:58 PM in reply to: wang890
If you want to remove the formatting overrides from MText you should just be able to set the:
MText.Contents = MText.Text

The Contents string holds all the text and formatting. Text just hold the text contents.

If the above removes too much of the formatting you may have to parse the Contents string and remove any of the unwanted formatting strings (in this case it is probably just the "\Fbold.shx;" at the start of the Contents string).

Edit: Removed extra slash.
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!