The Navisworks .NET API provides many events that we can listen to if we want to monitor the Navisworks product. The IApplicationGui events are mong them. In this article, let us look at some code in VB.NET for how to subscribe to these IApplicationGui events.
Imports System
Imports System.Text
Imports System.Linq
Imports System.Xml
Imports System.Reflection
Imports System.ComponentModel
Imports System.Collections
Imports System.Collections.Generic
Imports System.Windows
Imports System.Windows.Media.Imaging
Imports System.Windows.Forms
Imports System.IO
Imports Microsoft.Win32
Imports System.Runtime.InteropServices
Imports Autodesk.Navisworks.Api
Imports Autodesk.Navisworks.Api.Plugins
Imports Autodesk.Navisworks.Api.Controls
Imports Autodesk.Navisworks.Api.DocumentParts
Imports Autodesk.Navisworks.Api.ApplicationParts
Public Class IAppGuiEvents1
Dim mEventsObj As IApplicationGui
Public Sub New(ByVal obj As IApplicationGui)
mEventsObj = obj
End Sub
Public Sub Register()
AddHandler mEventsObj.Closing, AddressOf IAppGuiEvents_Closing_Handler
AddHandler mEventsObj.Closed, AddressOf IAppGuiEvents_Closed_Handler
End Sub
Public Sub UnRegister()
RemoveHandler mEventsObj.Closing, AddressOf IAppGuiEvents_Closing_Handler
RemoveHandler mEventsObj.Closed, AddressOf IAppGuiEvents_Closed_Handler
End Sub
Public Sub IAppGuiEvents_Closed_Handler(ByVal sender As Object, ByVal e As System.EventArgs)
'MessageBox.Show("Closed")
End Sub
Public Sub IAppGuiEvents_Closing_Handler(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs)
'MessageBox.Show("Closing")
End Sub
End Class
Navisworks .NET Addin Wizard provide such an item wizard, IApplicationGui Events handler, which can do all of these automatically in a moment. The leading edge Navisworks .NET Addin Wizard (NavisworksNetAddinWizard) can be found and downloaded from the A Wizard for Navisworks .NET Addin page.
Posted by: |