怎么用VBA在CAD布局图中加文字

2024-12-17 11:14:30
推荐回答(1个)
回答1:

Sub Example_AddText()

Dim textObj As AcadText
Dim textString As String
Dim insertionPoint(0 To 2) As Double
Dim height As Double

' Define the text object
textString = "Hello, World."
insertionPoint(0) = 2: insertionPoint(1) = 2: insertionPoint(2) = 0
height = 0.5
ThisDrawing.ActiveLayout = ThisDrawing.Layouts("布局2") '激活指定布局
' Create the text object in model space
Set textObj = ThisDrawing.PaperSpace.AddText(textString, insertionPoint, height) '在图纸空间(刚激活的)添加文字;
ZoomAll

End Sub