乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 48|回复: 0

修改的事件

[复制链接]

2

主题

2

帖子

2

银币

初来乍到

Rank: 1

铜币
10
发表于 2015-12-14 14:47:54 | 显示全部楼层 |阅读模式
大家好,我从autocad帮助中复制了这段代码,但我想创建一个具有句柄的对象事件,一个独立于其他子对象的事件,可以在autocad启动时或任何时候使用,我想创建具有一些句柄的数据库,当我更改一个特定对象时,也可以更改数据库,一个动态数据库,这不是很好
Autocad帮助中的代码:
  1. Public WithEvents PLine As AcadLWPolyline    ' Use with Modified Event Example
  2. Sub Example_Modified()
  3.      ' This example creates a lightweight polyline in model space and
  4.      ' references the PolyLine using the public variable (PLine) which
  5.      ' is set up to intercept Modified events.
  6.      '
  7.      ' This example then modifies the new object, triggering the code
  8.      ' in the Modified event.
  9.    
  10.     Dim points(0 To 9) As Double
  11.    
  12.     ' Define the 2D polyline points
  13.     points(0) = 1: points(1) = 1
  14.     points(2) = 1: points(3) = 2
  15.     points(4) = 2: points(5) = 2
  16.     points(6) = 3: points(7) = 2
  17.     points(8) = 4: points(9) = 4
  18.         
  19.     ' Create a lightweight Polyline object in model space
  20.     '
  21.     ' * Note: We are returning the new PolyLine object into a Module
  22.     ' level variable.  This allows us to intercept events associated
  23.     ' with that particular object.
  24.     Set PLine = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)
  25.    
  26.     ThisDrawing.Application.ZoomAll
  27.    
  28.     ' Modify object to trigger event.
  29.     '
  30.     ' * Note: The event code for the PolyLine modification will be triggered
  31.     ' before we move forward and refresh the view, so the line will not
  32.     ' appear blue when the event message box is displayed.
  33.     Dim color As AcadAcCmColor
  34.     Set color = AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor.20")
  35.     Call color.SetRGB(80, 100, 244)
  36.     PLine.TrueColor = color
  37.     ThisDrawing.Regen acAllViewports
  38.    
  39. End Sub
  40. Private Sub PLine_Modified(ByVal pObject As AutoCAD.IAcadObject)
  41.     ' This example intercepts an object's Modified event.
  42.     '
  43.     ' This event is triggered when an object supporting this event is modified.
  44.     '
  45.     ' To trigger this code: Modify an object connected to this event
  46.     ' * Note: By connected, we mean the object set up to intercept events using
  47.     ' the VBA WithEvents statement
  48.     ' Use the "pObject" variable to determine which object was modified
  49.     MsgBox "You just modified an object with an ID of: " & pObject.ObjectID
  50.    
  51. End Sub
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-4-20 05:08 , Processed in 0.573505 second(s), 55 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表