Drawing view doesnt UPDATE

Drawing view doesnt UPDATE

m_baczewski
Advocate Advocate
604 Views
11 Replies
Message 1 of 12

Drawing view doesnt UPDATE

m_baczewski
Advocate
Advocate

Hello,

 

In the drawing, I have 3 sheets. The rule works in such a way that when changing elements and parts in the assembly, the drawing should update and add balloons to the elements that appear. The problem is that it tries to add balloons on a sheet other than the first one, and on those sheets, I get an error that a certain edge doesn't exist. This is because the drawing hasn't updated yet. Only views on the first sheet are updating. When I check the UpToDate property, it appears that only views on the first sheet have True, while all views on other sheets have False. I've already tried:

oDoc.Update
oDoc.Update2
ThisApplication.ActiveDocument.Update
ThisApplication.ActiveDocument.Update2
InventorVb.DocumentUpdate()

None of these elements work. If I manually trigger the rule again, then it works fine. At this point, the rule is triggered during 'Drawing view change'. Do you have any idea?

 

m_baczewski_0-1709632260314.png

 

0 Likes
605 Views
11 Replies
Replies (11)
Message 2 of 12

FINET_Laurent
Advisor
Advisor

Hello @m_baczewski,

 

Have you tried activating the drawing document first, then looping through each sheet ->  activating the actual sheet -> using the sheet.Update() instead? 

 

Inventor 2024 Help | Sheet Object | Autodesk

 

Kind regards,

FINET L.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

0 Likes
Message 3 of 12

m_baczewski
Advocate
Advocate

@FINET_Laurent 

 

Yeah i have tried this one:

Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument

For Each oSheet As Sheet In oDoc.Sheets
	oSheet.Activate
	For Each oDrawingViews As DrawingView In oSheet.DrawingViews
		Logger.Info(oDrawingViews.UpToDate)
	Next
	oSheet.Update()
Next

 UpToDate=True is always for views on the sheet that was active when the automatic rule was triggered. For example, if I change the model and leave the drawing on sheet 3, the views on sheet 3 will have UpToDate=True.

0 Likes
Message 4 of 12

FINET_Laurent
Advisor
Advisor

@m_baczewski,

 

On this code, you are checking the update status  of the drawing view before updating the sheet. 🤔 Can you try this instead? : 

Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument

For Each oSheet As Sheet In oDoc.Sheets
	oSheet.Activate
	oSheet.Update()
	
	For Each oDrawingViews As DrawingView In oSheet.DrawingViews
		Logger.Info(oDrawingViews.UpToDate)
	
	Next	
Next

 

Kind regards,

FINET L.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

0 Likes
Message 5 of 12

m_baczewski
Advocate
Advocate

@FINET_Laurent 

 

It`s still nothing. After executing the rule, still 2 out of 3 sheets have a lightning and their UpToDate=False.

 

m_baczewski_0-1709634003091.png m_baczewski_2-1709634015258.png

 

 

0 Likes
Message 6 of 12

FINET_Laurent
Advisor
Advisor

@m_baczewski,

 

Then it depends of what needs to be updated. Have you tried the rebuild method the documents ?

Inventor 2024 Help | Document.Rebuild Method | Autodesk

 

Kind regards,

FINET L.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

0 Likes
Message 7 of 12

m_baczewski
Advocate
Advocate

@FINET_Laurent 

 

When i`m trying to use Rebuild i have got a error "Not implemented. (Exception from HRESULT: 0x80004001 (E_NOTIMPL))" or "Class undefined"

 

Dim oDoc As DrawingDocument = ThisDoc.Document
oDoc.Rebuild()

 

0 Likes
Message 8 of 12

Sergio.D.Suárez
Mentor
Mentor

I think You must first update the part and assembly models that are represented by the views


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes
Message 9 of 12

m_baczewski
Advocate
Advocate

@Sergio.D.Suárez 

When I change configurations in the model, it automatically updates the model at the very end.

 

RuleParametersOutput()
oDoc.Update
iLogicVb.UpdateWhenDone = True
0 Likes
Message 10 of 12

m_baczewski
Advocate
Advocate

I will describe strange behavior when I change model configurations and go to the drawing

2024-03-05_13h58_24.png

The rule automatically triggers because I have it set to run when the drawing view changes.

 

m_baczewski_1-1709644109581.png

 

In this rule, I have:

 

Dim oDoc As DrawingDocument
oDoc = ThisDoc.Document

oDoc.Sheets.Item(2).Update

 

Unfortunately, this doesn't work.

 

But I also have this part of the code in a TEST rule, and when I run the rule manually, it updates the sheet normally. Something blocked document update. What could be the cause of this?

0 Likes
Message 11 of 12

m_baczewski
Advocate
Advocate

It seems a bit like the automatic drawing update, which occurs after updating the model, is blocking the sheet update.

 

Maybe @WCrihfield or @A.Acheson can explain the weird behaviour?

0 Likes
Message 12 of 12

WCrihfield
Mentor
Mentor

Hi @m_baczewski.  @FINET_Laurent & @Sergio.D.Suárez already suggested most of what I would have suggested.  But now that I have seen the code you had in your Event Triggers dialog under the 'Drawing View Change' event, I would suggest changing that code a bit, so that it iterates through each sheet, activates it, updates it, then re-activates the original sheet again, sort of like the following example:

Sub Main
	Dim oDDoc As DrawingDocument = TryCast(ThisDoc.Document, Inventor.DrawingDocument)
	If oDDoc Is Nothing Then Return
	ThisDoc.ModelDocument.Update2(True)
	oDDoc.Update2(True)
	Dim oASheet As Sheet = oDDoc.ActiveSheet
	For Each oSheet As Sheet In oDDoc.Sheets
		oSheet.Activate
		oSheet.Update
	Next
	oASheet.Activate
	oDDoc.Update2(True)
End Sub

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes