The Navisworks .NET API provides many events that we can listen to if we want to monitor the Navisworks product. The DocumentInfoPart events are mong them. In this article, let us look at some code in VB.NET for how to subscribe to these DocumentInfoPart 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 DocInfoPartEvents1
Dim mEventsObj As DocumentInfoPart
Public Sub New(ByVal obj As DocumentInfoPart)
mEventsObj = obj
End Sub
Public Sub Register()
AddHandler mEventsObj.Changing, AddressOf DocInfoPartEvents_Changing_Handler
AddHandler mEventsObj.Changed, AddressOf DocInfoPartEvents_Changed_Handler
End Sub
Public Sub UnRegister()
RemoveHandler mEventsObj.Changing, AddressOf DocInfoPartEvents_Changing_Handler
RemoveHandler mEventsObj.Changed, AddressOf DocInfoPartEvents_Changed_Handler
End Sub
Public Sub DocInfoPartEvents_Changed_Handler(ByVal sender As Object, ByVal e As Autodesk.Navisworks.Api.SavedItemChangedEventArgs)
End Sub
Public Sub DocInfoPartEvents_Changing_Handler(ByVal sender As Object, ByVal e As System.EventArgs)
End Sub
End Class
Navisworks .NET Addin Wizard provide such an item wizard, DocumentInfoPart 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: |