Detect activate sheet in an idw

Detect activate sheet in an idw

Anonymous
Not applicable
424 Views
2 Replies
Message 1 of 3

Detect activate sheet in an idw

Anonymous
Not applicable

I'm programming in C# in inventor 2016/2017. I use this event to detect if a user activates a sheet.

 

private static Sheet oldval = null;
private static void ApplicationEvents_OnActivateView(Inventor.View vw, EventTimingEnum BeforeOrAfter, NameValueMap Context, out HandlingCodeEnum HandlingCode)
{
DrawingDocument drawingdoc = _inventorapp.ActiveDocument as DrawingDocument;
if (drawingdoc != null)
{
Sheet sheet = drawingdoc.ActiveSheet;
if (sheet == oldval)
{
HandlingCode = Inventor.HandlingCodeEnum.kEventHandled;
return;
}
oldval = sheet;
ExecuteTools.SetStartupValue(_inventorapp, drawingdoc);
}
HandlingCode = Inventor.HandlingCodeEnum.kEventHandled;
}

 

There are two problems. First of all, when I open an IDW and activate a sheet, the code above is repeatedly being accessed. Even though I kEventHandled is Handled, it keeps returning in this function with the HandlingCode being back at nothandled.

 

Second problem, This code isn't being called for when I have an IDW with several sheets in it. When I activate another sheet in the same IDW, the 

OnActivateView isn't called. What event do I need to use for this ?

 

0 Likes
Accepted solutions (1)
425 Views
2 Replies
Replies (2)
Message 2 of 3

bshbsh
Collaborator
Collaborator
Accepted solution

If memory serves (so I am likely wrong 🙂 ), the OnNewEditObject fires on sheet change. Save the ActiveSheet.Name on the before trigger, then compare this to the "new" ActiveSheet.Name on the after trigger to see if it was a sheet change or something else.

Message 3 of 3

Anonymous
Not applicable

Yes, the OnNewEditObject works like a charm, Excellent! If you where a beautifull woman I would kiss you 🙂

Thanks a lot.

0 Likes