Computer Aided Automation

Full Version: AutoCAD VBA code to insert text
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Insert Text

add a button then copy below code 
to adjust the location (positon of the text) change 

insertionPoint2(0) - for X coordinate
insertionPoint2(1) - for Y coordinate
insertionPoint2(2) - for Z coordinate

Private Sub CommandButton1_Click()
Dim textObj2 As AcadText
Dim insertionPoint2(0 To 2) As Double

Dim textString2 As String

' Define the text object
    textString2 = "Drawn by : "
    insertionPoint2(0) = 10: insertionPoint2(1) = 10: insertionPoint2(2) = 0
    Height = 4
        ' Create the text object in model space
    Set textObj2 = ThisDrawing.ModelSpace.AddText(textString2, insertionPoint2, Height)

End Sub