Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to save all changes via macro?

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
ack509
3197 Views, 9 Replies

How to save all changes via macro?

Hello,

 

We want to change iassemblies in a table using macro. When we change an iassemblies, inventor asks "Do you want to save changes to ......?". There are many iassemblies in our model, so it takes serious amount of time. We can disable all messages using macro, But this time after macro completion, there may be some errors in model, because we dont accept all changes. How can we accept all changes while running macro?

 

We use SilentOperation property. but in Save dialog, there are some parts indicated "yes" and some indicated "no". how can we change them "yes" and save all dependents?

 

Thank you in advance

9 REPLIES 9
Message 2 of 10
ack509
in reply to: ack509

Hi,

 

I also attached a screen shot.

 

Message 3 of 10
YuhanZhang
in reply to: ack509

Use Save2 you can specify if you want to save all the dependent documents if they are dirty with setting the DocuemntsToSave argument.

 

Hope this helps!



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.

Message 4 of 10
ack509
in reply to: YuhanZhang

Thank you Zhang for your reply.

 

we used save2. it saved all dependents have default "Yes" but there were "No" selected items in the list as seen in the attachment named resim2.jpg. As you say,we should use DocumentsToSave option, but we dont know what to type there (resim1.jpg). can you explain what it stands for? what should we write there to save all dependents selected "No" as default.

 

Thank you again.

Message 5 of 10
YuhanZhang
in reply to: ack509

Seems that you want to save all the dependent(referenced) documents no matter they need a "save" or not, right? As usual only the document which is dirty(modified/migrated) will need a save, so Inventor will detect this and set the "No" to a dependent if it is not dirty. While if you still want to change the "No" to "Yes", from API side what you should do is to set the Document.Dirty = True. So in your case if you want to save all the dependents no matter they are dirty or not, you could transverse over all the ReferencedDocumentDescriptors, and set them to dirty. Below is a sample VBA code:

 

    ' This is the document being saved
    Dim oDoc As Document
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oRefDoc As Document
    Dim oRefDocDesc As DocumentDescriptor
    
    ' make all the referenced documents dirty
    For Each oRefDocDesc In oDoc.ReferencedDocumentDescriptors
        Set oRefDoc = oRefDocDesc.ReferencedDocument
        oRefDoc.Dirty = True
    Next

    ' Save the document and its dependents.
    Call oDoc.Save2(True)

 



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.

Message 6 of 10
ack509
in reply to: YuhanZhang

Thank you so much
Message 7 of 10
craigzcool
in reply to: ack509

Hi, im having the same problem, ive got a program that goes through a for loop and generates multiple drawings from a list of parts. I cant use the Save2 or Save commands because the drawing hasnt been created yet. And every loop it keeps asking "Do you want to save changes to "Part1.idw" and its dependents?"

 

Please help!

 

Thanks in advance

Message 8 of 10
YuhanZhang
in reply to: craigzcool

You can use SilentOperation to suppress the dialogs like below:

 

        invApp.SilentOperation = True
        For Loop Start

            TempFileName = "NewPartEachTime.ipt"
            oPartDoc = invApp.Documents.Open(TempFileName)
   
            oDrawDoc = invApp.Documents.Add(Inventor.DocumentTypeEnum.kDrawingDocumentObject, "C:\Users\Public\Documents\Autodesk\Inventor 2013\Templates\\IDW PART.idw", True)

            Str = Destination & oPartDoc.DisplayName & ".idw"
            oPartDoc.Close(True)

            oDrawDoc.SaveAs(Str, False)
            oDrawDoc.Close(True)
        Next
        invApp.SilentOperation = False

 

 



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.

Message 9 of 10
DeerSpotter
in reply to: YuhanZhang

how would i suppress the following image with this silent option or code?

Image and video hosting by TinyPic
..........................................................................................................................
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
..........................................................................................................................


See My LinkedIn Profile
Message 10 of 10
YuhanZhang
in reply to: DeerSpotter

The SilentOperation should work for Inventor dialogs, but not work for other dialogs, so you can try other code like SendKeys in VB to send keys to the active dialog to suppress it.

 

Hope this helps!



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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report