Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use AutoCAD events in VB.NET

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article is about how to use AutoCAD events in VB.NET. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

In ObjectARX, we use reactors to encapsulate VB.NET AutoCAD events. In AutoCAD.NET API, we can use events instead of ObjectARX reactors.

Typically, the steps to handle the VB.NET AutoCAD event are as follows:

1. Create an event handler

When an event occurs, the event handler (or callback function) is called. Any action that we want to handle in response to the VB.NET AutoCAD event is done in the event handler.

For example, suppose we just want to notify the user that an AutoCAD object has been added. We can do this using the AutoCAD database event "ObjectAppended". We can write a callback function (event handler) as follows:

Sub objAppended (ByVal o As Object, ByVal e As ObjectEventArgs) MessageBox.Show ("ObjectAppended!") 'add some code End Sub here

The * * parameters in the function represent the AutoCAD database. The second parameter represents the ObjectEventArgs class, which may contain data that is useful for the processing function.

two。 Associate event handlers with events

In order to start monitoring actions, we must associate event handlers with events. Here, the ObjectAppended event occurs when an object is added to the database. However, the event handler will not respond to this event unless we associate it with this event, for example:

Dim db As Database

Db = HostApplicationServices.WorkingDatabase ()

AddHandler db.ObjectAppended, New ObjectEventHandler (AddressOf objAppended)

3. Disconnect event handler

To stop monitoring an action, we must disconnect the event handler from the event. When the object is added, we want to stop notifying the user of this event, and we want to disconnect the event handler from the event ObjectAppended.

RemoveHandler db.ObjectAppended, AddressOf objAppended, thank you for reading! This is the end of this article on "how to use AutoCAD events in VB.NET". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report