Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AutoCAD VBA code to insert text
#1
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()
Me.Hide
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
Reply
#1
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()
Me.Hide
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
Reply
CAA


Forum Jump:


Users browsing this thread: 1 Guest(s)