Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Drawing "Update" event

DRoam
Mentor

Drawing "Update" event

DRoam
Mentor
Mentor

I'm trying to hook up some custom actions to the "Update Drawing" event, so they happen immediately after a drawing is updated. I can easily watch for manual updates and respond to those. The problem is, Inventor also automatically updates drawings after certain actions, such as opening or activating an out-of-date drawing. I can't figure out how to watch for these automatic Updates.

 

I tried watching the "OnDocumentChange" event, but this event isn't triggered by Inventor's automatic updates.

 

I could easily check for an OnOpenDocument or OnActivateDocument event, but these don't tell me whether the drawing is going to be updated as part of the open/activate or not, and I don't want my code running unless an Update is actually happening.

 

My last idea was to check the "DrawingDocument.RequiresUpdate" property BEFORE an open/activate event and again AFTER it, and if "RequiresUpdate" changed from True to False, then the drawing was updated. Surprisingly, this worked for the OnActivateDocument event. However, "RequiresUpdate" always returns False inside of the "OnOpenDocument" event. So I can't tell if a drawing was updated during opening.

 

So, my questions:

  1. Is there a simple, fool-proof way to watch for the "automatic drawing update" event?
  2. If not, is there a way to determine if an Update is going to happen during a drawing Open event, since "RequiresUpdate" always returns False during an open?
0 Likes
Reply
531 Views
6 Replies
Replies (6)

DRoam
Mentor
Mentor

Is that a no?

 

PS, I'm not sure why I put "view" in the title. Please ignore that. It should just say, Drawing "Update" event.

0 Likes

YuhanZhang
Autodesk
Autodesk

Can you share what you want to do when drawing is being updated?



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes

JaneFan
Autodesk
Autodesk

Hey @DRoam , 

 

The first thing coming to my mind for this requirement is using OpenWithOptions to open the drawing file with setting DeferUpdates to True: 

Dim oNM As NameValueMap
Set oNM = ThisApplication.TransientObjects.CreateNameValueMap
oNM.Add "DeferUpdates", True
Dim oDoc As DrawingDocument
Set oDoc = ThisApplication.Documents.OpenWithOptions("Path\part.idw", oNM)

 

By opening drawing file with defer update setting to True, it should work combining what you mentioned using DrawingDocument.RequiresUpdate: 

Dim bUpdated As Boolean 
If oDoc.RequiresUpdate = True Then 
'Setting DrawingSettings.DeferUpdates to False to apply update in such case oDoc.DrawingSettings.DeferUpdates = False bUpdated = True MsgBox(bUpdated) End If   



Jane Fan
Inventor QA Engineer
0 Likes

DRoam
Mentor
Mentor

Hi @YuhanZhang, my add-in is supposed to manage certain things about the drawing, such as information in text fields and which parts are shown in Parts Lists. These need to stay up to date with changes to referenced documents, but I don't want my code running unnecessarily. I assumed the most efficient way to do this would be to "hook in" to the built-in Update and run my code whenever it does.

0 Likes

DRoam
Mentor
Mentor

@JaneFan thanks for the suggestion, that might work. As long as I can make sure Defer Updates isn't already On before I open the drawing. I don't want to turn it off and update the drawing if updates are supposed to be deferred.

 

I've had to put this project on hold for now but I'll update you on how that works out when I get the chance to try it.

0 Likes

YuhanZhang
Autodesk
Autodesk

So sounds like you just want to make sure the drawing is up-to-date when you manage the drawing objects to get info from them, I guess what you want is not just to hook up the event when Update is happening, but needs the drawing is updated when you get the info. If yes you can do some check if the drawing is updated, and you can even call the DrawingView.[_Update], Sheet.Update and DrawingDocument.Update to make sure the drawing document is up-to-date before you manage the drawing objects.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes