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

How to check if a file has been saved in Inventor 2022?

CattabianiI
Collaborator

How to check if a file has been saved in Inventor 2022?

CattabianiI
Collaborator
Collaborator

This one is a well known code snippet to check if a file has been saved in Inventor 2021 and previous versions:

if Document.FileSaveCounter > 0 then


Since the document and file now are different elements that property could not be the one we were looking for.
Fortunately it's already there the proper one which is:

Document.File.FileSaveCounter


Why? What's now the Document.FileSaveCounter? How can be Document.FileSaveCounter = 0 and no save needed? 

...

This is the biggest Inventor update in many years as you, Autodesk, often says and it's having an even bigger impact on .NET API devs.
No more posts on the inventor API blogs, just the LODs migration document written one year ago, many things has changed in the updates without any mention in the release notes.

0 Likes
Reply
821 Views
3 Replies
Replies (3)

pball
Advisor
Advisor

I do not see any difference in the behavior in 2022 though I'm on vanilla 2022 without any updates as I can't install them.

 

debug.Print thisapplication.activeeditdocument.FileSaveCounter
1 'after save
0 'before save

 

debug.Print thisapplication.ActiveEditDocument.File.FileSaveCounter
1 'after save
0 'before save

Check out my style edits for the Autodesk forums
pball's Autodesk Forum Style
0 Likes

CattabianiI
Collaborator
Collaborator

You're totally right, there isn't any difference if you don't use model states nor substitutes.

 

In any other case there are differences!

0 Likes

pball
Advisor
Advisor

That may have been a good point to note originally. I haven't actively started using 2022 yet so I haven't touched model states yet.

Check out my style edits for the Autodesk forums
pball's Autodesk Forum Style
0 Likes