Automating Update Model in Drawings

Automating Update Model in Drawings

m_elsabbahyMDT3V
Community Visitor Community Visitor
138 Views
1 Reply
Message 1 of 2

Automating Update Model in Drawings

m_elsabbahyMDT3V
Community Visitor
Community Visitor

Hi all,

I’m trying to create an ilogic external rule in Autodesk Inventor 2024 to automatically update all drawing views in all sheets of an open .idw or .dwg drawing. Specifically, I need to replicate the “Update Model” command you get when right-clicking a drawing view → Update Model.

Here’s what I’ve tried so far:

  • Using Sheet.Update() and DrawingDocument.Update(), but this only updates the sheet graphics/annotations, not the model link.

  • Attempting to call DrawingView.Update() directly, but this property doesn’t exist in the Inventor 2024 API.

  • Calling ControlDefinitions like "DrawingUpdateAll", which caused errors (“Class not registered”).

  • Experimenting with ReferencedDocument.Update(), but that risked corrupting files.

The goal is to loop through all sheets and all views in a drawing, and actually refresh the referenced model data (as if “Update Model” was clicked for each view).

Environment:

  • Autodesk Inventor 2024

  • Windows 10/11

  • Using iLogic external rules (VB.NET style)

Has anyone solved this before or knows the correct API call or workflow to programmatically trigger “Update Model” on all drawing views?
Any code snippets, API references, or guidance would be appreciated!

Thanks in advance.

0 Likes
139 Views
1 Reply
Reply (1)
Message 2 of 2

WCrihfield
Mentor
Mentor

Hi @m_elsabbahyMDT3V.  In iLogic rules, we have a convenient tool that is unique to iLogic, which gives us access to 'the model' document (ThisDoc.ModelDocument).  The term 'ThisDoc' is a 'Rule Object' which represents an 'ICadDoc' object.  I use that term in most of my iLogic rules, instead of using the 'ThisApplication.ActiveDocument' property, because it is far more dynamically useful & appropriate in more situations.

Anyways, we could simply try something like this:

ThisDoc.ModelDocument.Update

...but I usually like to avoid potential errors (such as no model yet), and be a bit more thorough, so I just quickly typed-up the example code below.  Sometimes updating a drawing has to be done in multiple steps.  Like when you update the drawing, then it tells you the model needs to be updated.  Then you update the model.  Then it tells you the drawing needs to be updated again, so you do that, then sometimes one or more views take a little while to update, and become 'raster' few seconds then back to accurate.  Doing a deep update on the model is usually a first step, when a code process is going between model and drawing, making changes to both.

The example below first gets the drawing.  Then gets 'the model'.  Then updates the model.  Then updates the drawing.  Then iterates through each sheet, simulating the process of replacing the model reference in each view, with the same model, just to force an update, just in case the previous step didn't get the job done.  Then it updates the sheet.

Dim oDDoc As DrawingDocument = TryCast(ThisDoc.Document, DrawingDocument)
If oDDoc Is Nothing Then Return
Dim oMDoc As Inventor.Document = ThisDoc.ModelDocument
If oMDoc Is Nothing Then Return
'oMDoc.Rebuild2(True)
oMDoc.Update2(True)
oDDoc.Update2(True)
For Each oSheet As Inventor.Sheet In oDDoc.Sheets
	For Each oDView As DrawingView In oSheet.DrawingViews
		Dim oRFD As FileDescriptor = oDView.ReferencedDocumentDescriptor.ReferencedFileDescriptor
		oRFD.ReplaceReference(oRFD.FullFileName)
	Next 'oDView
	oSheet.Update()
Next 'oSheet

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)