.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to create a Mtext with 2 lines each line with different color?

1 REPLY 1
Reply
Message 1 of 2
dancalgary
281 Views, 1 Reply

how to create a Mtext with 2 lines each line with different color?

I have this code:
I don't know how to make that line 1 to be red and line 2 to be green inside the Mtext
Can somebody help me?
Thanks


Dim ThisDrawing As Autodesk.AutoCAD.ApplicationServices.Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim Editor1 As Autodesk.AutoCAD.EditorInput.Editor
Editor1 = ThisDrawing.Editor

Using Trans2 As Autodesk.AutoCAD.DatabaseServices.Transaction = thisDrawing.TransactionManager.StartTransaction


Dim BlockTable1 As Autodesk.AutoCAD.DatabaseServices.BlockTable
Dim BTrecord As Autodesk.AutoCAD.DatabaseServices.BlockTableRecord
BlockTable1 = ThisDrawing.Database.BlockTableId.GetObject(OpenMode.ForRead)
BTrecord = Trans2.GetObject(ThisDrawing.Database.CurrentSpaceId, OpenMode.ForWrite)


Dim Mtext1 As New Autodesk.AutoCAD.DatabaseServices.MText()
Mtext1.Contents = “This is line 1” & vbCrLf & “This is line 2”
Mtext1.Location = New Autodesk.AutoCAD.Geometry.Point3d(10, 10, 0)

BTrecord.AppendEntity(Mtext1)
Trans2.AddNewlyCreatedDBObject(Mtext1, True)
Trans2.commit
End using
1 REPLY 1
Message 2 of 2

in your text string use the the following syntax
{\C1;Line1}\P{\C2;Line2}

The number after {\C is the autocad colour

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost