CAD Forum - tips, tricks, discussion and utilities for AutoCAD, Inventor, Revit and other Autodesk products [www.cadforum.cz] ARKANCE | CONTACT - CZ | SK | EN | DE
Over 1.091.000 registered users (EN+CZ). AutoCAD tips, Inventor tips, Revit tips. Try the new precise Engineering calculator. New AutoCAD 2026 commands and variables.
RSS channel - CAD tips RSS tips
RSS discussions

Discussion Discussion forum

?
CAD discussions, advices, exchange of experience

CAD Forum - Homepage CAD discussion forum - ask any CAD-related questions here, share your CAD knowledge on AutoCAD, Inventor, Revit and other Autodesk software with your peers from all over the world. To start a new topic, choose an appropriate forum.

Please abide by the rules of this forum.
This is a peer-to-peer forum. The forum doesn't replace the official direct technical support provided by ARKANCE for its customers.
How to post questions: register or login, go to the specific forum and click the NEW TOPIC button.
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

add mttext with color

 Post Reply Post Reply
Author
katto01 View Drop Down
Newbie
Newbie


Joined: 24.Jun.2009
Location: Japan
Using: ZWCAD
Status: Offline
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote katto01 Quote  Post ReplyReply Direct Link To This Post Topic: add mttext with color
    Posted: 20.Nov.2024 at 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?

Thanks


Sub 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.ZoomExtents
End Sub

Katto Ishimura
Back to Top

Related CAD tips:


 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down



This page was generated in 0,061 seconds.