AutoVBA獲取基本圖元對象,以LINE為例,代碼如下。
Public Sub animatedline()
Dim mylineobject As AcadLine
Dim startmovevector(0 To 2) As Double
Dim endmovevector(0 To 2) As Double
Dim count As Integer, start As Single
Set mylineobject = ThisDrawing.ModelSpace.Item(0)
For count = 1 To 10
startmovevector(0) = count
startmovevector(1) = count
startmovevector(2) = count
endmovevector(0) = count + 1
endmovevector(1) = count + 1
endmovevector(2) = count + 1
mylineobject.Move startmovevector, endmovevector
start = Timer
While Timer < start + 0.05
Wend
ZoomAll
mylineobject.Update
Next
End Sub
代碼完。
圖元對象就是基本的面向對象的思想,任何一個圖元都是一個類的實例,繪圖空間是各個類的實例顯示的舞臺。