Public WithEvents PLine As AcadLWPolyline Sub CreatePLineWithEvents() ' 本例创建一细多义线 Dim points(0 To 9) As Double points(0) = 1: points(1) = 1 points(2) = 1: points(3) = 2 points(4) = 2: points(5) = 2 points(6) = 3: points(7) = 3 points(8) = 3: points(9) = 2 Set PLine = ThisDrawing.ModelSpace.AddLightWeightPolyline(points) PLine.Closed = True Dim pt1(0 To 5) As Double Dim pt2(0 To 2) As Double pt1(0) = 0: pt1(1) = 0: pt1(2) = 2 pt1(3) = 2: pt1(4) = 4: pt1(5) = 5 Set PLine = ThisDrawing.ModelSpace.AddLightWeightPolyline(pt1) PLine.Closed = True
ThisDrawing.Application.ZoomAll End Sub
Private Sub PLine_Modified _ (ByVal pObject As AutoCAD.IAcadObject)
On Error GoTo ERRORHANDLER MsgBox "对象" & pObject.ObjectName & " 的面积为: " _ & pObject.Area Exit Sub
ERRORHANDLER: MsgBox Err.Description End Sub
以上的代码,顺利执行后,只有在图形中改动后来创建的PLine对象,才触发事件。但是改变前一个PLine对象,并不触发。我的要求是创建多个PLine对象,(我试了一下,用数组PLine(0),PLine(1)不行)如何改变任何一个对象,都触发对象改动事件么?
谢谢指教。