Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ilogic, Assembly save all dependants

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
Jacques.Grobler
1811 Views, 7 Replies

ilogic, Assembly save all dependants

Hi all

 

Is it possible not to have inventor prompt to save or not to save all parts in an assembly when pressing save?

 

I would prefer all parts to be automatically saved with no prompt box when I run thisdocument.save

7 REPLIES 7
Message 2 of 8
mrattray
in reply to: Jacques.Grobler

Try using Document.Save2
Mike (not Matt) Rattray

Message 3 of 8
Jacques.Grobler
in reply to: mrattray

Hi Mike

Sorry but I cannot find any reference to Document.Save2
Message 4 of 8
mrattray
in reply to: Jacques.Grobler

Capture.JPG

 

Capture.JPG

Mike (not Matt) Rattray

Message 5 of 8
Jacques.Grobler
in reply to: mrattray

Tx Mike

 

As I posted my reply I stumbled upon this:

 

' This is the document being saved
Dim oDoc As Document
oDoc = ThisApplication.ActiveDocument

Dim oRefDoc As Document
Dim oRefDocDesc As DocumentDescriptor

' make all the referenced documents dirty
For Each oRefDocDesc In oDoc.ReferencedDocumentDescriptors
    oRefDoc = oRefDocDesc.ReferencedDocument
    oRefDoc.Dirty = True
Next

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

 which includes the Document.Save2

Message 6 of 8

Hi and thanks for your contribution.

 

I tried this code but got an error when one of the components was patterned and one instance of the pattern was suppressed

 

Error:

Error in rule: Change hood, in document: Rect Hood.iam

Object reference not set to an instance of an object.

 

Took my a couple of hours to find the cause because it had been working untill I suppresed an instance of the pattern through iLogic.

It seems to stumble on the mark dirty part of the refence documents, from what I can see at least (beiing the beginner programmer I am)

 

If I comment out the following it works again:

Dim oRefDocDesc As DocumentDescriptor

' make all the referenced documents dirty
For Each oRefDocDesc In oDoc.ReferencedDocumentDescriptors
    oRefDoc = oRefDocDesc.ReferencedDocument
    oRefDoc.Dirty = True
Next

 

Is there a trick to get past this? Because I need to get all the parts updated before I export them to a drawing. 

 

Cheers

Rudrugis

Message 7 of 8
sigurdurie
in reply to: sigurdurie

I changed the Call to Save2 to:

SyntaxEditor Code Snippet

Call oDoc.Save2(True,SaveDependents)

And it seems to do what I'm after

 

Cheers

Rudrugis

Message 8 of 8
sigurdurie
in reply to: sigurdurie

The deeper I dig the more unnecessary the loop seems to be because from what I gather the call to Save2:

 

SyntaxEditor Code Snippet

Dim oDoc As Document
oDoc = ThisApplication.ActiveDocument
Call oDoc.Save2(True)

Does infact safe all dependents i.e. searches for parts marked as "dirty" and saves them if they have changed.

 

I might be wrong of course but maybe someone can set me straight regarding this or confirm it?

 

Cheers

Rudrugis

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

Post to forums  

Autodesk Design & Make Report