Inventor .NET Addin Wizard (InventorNetAddinWizard) provides kinds of Event Handler Wizards to help automatically and intelligently generate start code for even handlers and register them in a chosen Inventor addin server class when applicable.
The Inventor .NET Part Events wizard is one of them. After a source file name is given and the Add button pressed, the event wizard Welcome page, Event Chosen page, Naming Convention and Addin Server chosen page, and Summary page will show up one after another.
If all events are chosen and other settings are like above, the even handler class will look like this:
using System;
using System.Text;
using System.Linq;
using System.Xml;
using System.Reflection;
using System.ComponentModel;
using System.Collections;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Media.Imaging;
using System.Windows.Forms;
using System.IO;
using Microsoft.Win32;
using System.Runtime.InteropServices;
using Inventor;
namespace InventorNetAddinCS
{
public class PartEventHanlder1
{
private PartEvents mEventsObj;
public PartEventHanlder1(PartEvents obj)
{
mEventsObj = obj;
}
public void Register()
{
mEventsObj.OnSurfaceBodyChanged += PartEvents_OnSurfaceBodyChanged_Handler;
}
public void UnRegister()
{
mEventsObj.OnSurfaceBodyChanged -= PartEvents_OnSurfaceBodyChanged_Handler;
}
public void PartEvents_OnSurfaceBodyChanged_Handler(NameValueMap Context, EventTimingEnum BeforeOrAfter, out HandlingCodeEnum HandlingCode)
{
MessageBox.Show("OnSurfaceBodyChanged");
HandlingCode = HandlingCodeEnum.kEventHandled;
}
}
}
The leading edge Inventor .NET Addin Wizard (InventorNetAddinWizard) can be found and downloaded from the A Wizard for Inventor .NET Addin page.
Posted by: |