katto01
20.11.2024, 10:33
Hello,I am trying to plot a few text objects with different colors.Here is the code I have. the color is black rather than red.Any suggestions?ThanksSub AddMTextWithTrueColor() ' Declare variables Dim mTextObj As Object Dim insertionPoint(0 To 2) As Double Dim textContent As String Dim trueColor As Long ' Set the insertion point for the MText (e.g., 0,0,0) insertionPoint(0) = 0 insertionPoint(1) = 0 insertionPoint(2) = 0 ' Set the text content textContent = "This is an example of MText with True Color." ' Set the True Color (e.g., RGB(255, 0, 0) = Red) trueColor = RGB(255, 0, 0) ' Red color ' Create MText object at the specified insertion point Set mTextObj = ThisDrawing.ModelSpace.AddMText(insertionPoint, 50, textContent) ' Set the True Color of the MText object mTextObj.Color = trueColor ' Use Color property to set the True Color ' Optionally, you can set the text height, width, rotation, etc. mTextObj.TextHeight = 2 ' Set the text height to 2 units ' Zoom to the new object for better visibility ThisDrawing.ActiveViewport.ZoomExtentsEnd Sub