明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1671|回复: 1

[求助]关于事件的使用

[复制链接]
发表于 2004-7-10 23:14 | 显示全部楼层 |阅读模式
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)不行)如何改变任何一个对象,都触发对象改动事件么? 谢谢指教。
发表于 2004-7-11 03:49 | 显示全部楼层
这样行不通的,应该启用文档层次的事件AcadDocument_ObjectModified监视所有的图元修改
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-18 02:38 , Processed in 0.220188 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表