By Adam Nagy
Each drawing view has its own DrawingViewEvents object and the event you subscribe to through it is specific to that DrawingView. However, the event itself does not tell you which object triggered it.
If you want to listen to this event sent by only a couple of the drawing views then you can create a separate event handler function for each, and that way identify which DrawingView object sent it:
using System; using System.Runtime.InteropServices; using System.Collections.Generic; using Inventor; using MsgBox = System.Windows.Forms.MessageBox; namespace InventorConsoleCs { class Program { static DrawingView dw1, dw2; static void Main(string[] args) { Application app = (Application) Marshal.GetActiveObject("Inventor.Application"); DrawingDocument doc = (DrawingDocument)app.ActiveDocument; dw1 = doc.ActiveSheet.DrawingViews[1]; dw1.DrawingViewEvents.OnViewUpdate += DrawingViewEvents_OnViewUpdate1; dw2 = doc.ActiveSheet.DrawingViews[2]; dw2.DrawingViewEvents.OnViewUpdate += DrawingViewEvents_OnViewUpdate2; System.Console.ReadKey(); } static void DrawingViewEvents_OnViewUpdate1( EventTimingEnum BeforeOrAfter, NameValueMap Context, CommandTypesEnum ReasonsForChange, out HandlingCodeEnum HandlingCode) { HandlingCode = HandlingCodeEnum.kEventNotHandled; MsgBox.Show(dw1.Name); } static void DrawingViewEvents_OnViewUpdate2( EventTimingEnum BeforeOrAfter, NameValueMap Context, CommandTypesEnum ReasonsForChange, out HandlingCodeEnum HandlingCode) {
HandlingCode = HandlingCodeEnum.kEventNotHandled; MsgBox.Show(dw2.Name); } } }


Leave a Reply