how to see if a file has edits and needs saved

how to see if a file has edits and needs saved

ChristiPedersen
Advocate Advocate
415 Views
6 Replies
Message 1 of 7

how to see if a file has edits and needs saved

ChristiPedersen
Advocate
Advocate

is there a way in VBA to see if an Inventor file has edits and needs saved?

0 Likes
416 Views
6 Replies
Replies (6)
Message 2 of 7

bradeneuropeArthur
Mentor
Mentor
This is via the
Ducument.dirty
Document.updaterequired

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 7

CattabianiI
Collaborator
Collaborator

Hi @bradeneuropeArthur 
I think you mean: RequiresUpdate 😉

 

Can I ask when do you use RequiresUpdate? 
If the document is NOT dirty but requires update I suppose that without saving no information is lost, just still needs that update when it's opened again. Am I right?

0 Likes
Message 4 of 7

WCrihfield
Mentor
Mentor

I sometimes use it near the end of a rule that may, or may not have, made changes to the document.  Sometimes for the sake of reducing needed processing, I will check if things are set a certain way before attempting to set the the way I want them.  That way, it is not forcing changes that are not needed, which would dirty the document unnecessarily.  After some code like that, I will often use a couple of lines similar to the following:

If oDoc.RequiresUpdate Then oDoc.Update2(True)
If oDoc.Dirty Then oDoc.Save2(False)

...because it is possible that nothing has been changed, but if changes were made, the document likely needs to be updated, then saved.  But I don't want to update or save the document if it is not necessary.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 5 of 7

CattabianiI
Collaborator
Collaborator

Thanks @WCrihfield, what I would like to understand is if it's a check to avoid possible loss of information or it's just to know if updates are required.
I understand and I agree on your pattern which is the best one for real use case, but let's say I pay one credit for each save I could write something like this and still be sure to not loose information? (as far as I know: Yes!)

if doc.Dirty then
  if doc.RequiresUpdate then
    ' do the update (it's free now!) and save
    oDoc.Update2(True)
    oDoc.Save2(False)
  end if
else
  if doc.RequiresUpdate then
    ' do nothing to save 1 credit!
    ' I'm okay to update this doc another time
    MsgBox("You Scrooge! Remember to update this document another time especially if you want the drawing up-to-date!")
  end if
end id

 

Message 6 of 7

WCrihfield
Mentor
Mentor

OK.  For me, it is mainly just face value...I use it to know if updates are required in some situations, not so much to save data, but for the peace of mind, because I don't always use both lines together, so the 'Dirty' check, and the Save is sort of a secondary.  For instance, if I am going to export several parts in a folder out to STEP files, or generate DXF's from their faces/flat patterns, I often want to ensure several specific preparations are in place before exporting them, but I may not want to save the original model file after the changes, just export the possibly changed files.  These changes may already be in place, so no changes may be needed, but others will need to be changed, and I know that certain changes are not usually visible until after an update or rebuild has been performed.  I want to be extra sure that the several possible changes have been applied to the documents, if needed, before they get exported, because I don't want to have to open each one and check things after the exports.  It just seems like a fairly efficient layer of reassurance in the process.  I suppose you could argue that it seems like I'm worried about the changes being present in the exported files, so it is still about saving data, but this is just one scenario among many possibilities.  Its actual validity/usefulness in some situations may be questionable and worth further study, but it is a nice property to have available.  Good food for thought.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 7 of 7

bradeneuropeArthur
Mentor
Mentor
I was far from my desk and typing from my mobile.
That is why I was making mistake.
You are fully right.

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes