How to save and close a .SAT extension file opened in Inventor through API's

How to save and close a .SAT extension file opened in Inventor through API's

Anonymous
Not applicable
761 Views
6 Replies
Message 1 of 7

How to save and close a .SAT extension file opened in Inventor through API's

Anonymous
Not applicable

Hi

 

I opened a .SAT extension file in Inventor and i modified the iproperties and trying to save the Assembly document but its not happening..

 

so can anyone know how to do that

 

code is as follows:

Inventor.Application InvApp = Activator.CreateInstance(Type.GetTypeFromProgID("Inventor.Application")) as Inventor.Application;
InvApp.Visible = true;
Inventor.AssemblyDocument AsmDoc = (Inventor.AssemblyDocument) InvApp.Documents.Open("Pathname");

 

********

*******

*****

AsmDoc.Save();

AsmDoc.SaveAs("pathname", true);
AsmDoc.Close(true);
InvApp.Quit();

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

YuhanZhang
Autodesk
Autodesk

Not quite sure what you mean "its not happening...", can you provide your .sat file(don't send confidential data) and working code sample, and also tell which code line does not work as expected?



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.

0 Likes
Message 3 of 7

Anonymous
Not applicable

Hi YuhanZhang

 

Open any .SAT file in Inventor through code and make any change to that file through API's and try to save it. 

the changes are not reflecting through code.

so my question is how to save the .SAT file after making changes through API

 

Thanks & Regards

Niranjan

0 Likes
Message 4 of 7

YuhanZhang
Autodesk
Autodesk

I can't catch what the problem you mean, but I created a VBA sample code to verify it, you can copy it to Inventor VBA Editor, and change the file name of .sat to yours and run it:

Sub test()
    Dim oDoc As AssemblyDocument
    Set oDoc = ThisApplication.Documents.Open("C:\Temp\Sat.sat", True)
    
    
    ' do some change to the assembly
    Dim oDV As DesignViewRepresentation
    Set oDV = oDoc.ComponentDefinition.RepresentationsManager.DesignViewRepresentations.Add("All Hidden")
    
    Dim oOccu As ComponentOccurrence
    For Each oOccu In oDoc.ComponentDefinition.Occurrences
        oOccu.Visible = False
    Next
    
    ' save the assembly document
    Call oDoc.Save2(True)
    
    Dim sFileName As String
    sFileName = oDoc.FullFileName
    
    ' close the assembly
    oDoc.Close
    
    ' reopen the saved assembly to check if the change was saved
    Set oDoc = ThisApplication.Documents.Open(sFileName, True)
    oDoc.ComponentDefinition.RepresentationsManager.DesignViewRepresentations("All Hidden").Activate
End Sub

Can you run the VBA code there to see if it works with your SAT file?



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.

0 Likes
Message 5 of 7

Anonymous
Not applicable

Hi

 

i tried doing this..but the changes are not saved by the code you mentioned below.. Can you try it once..

 

 

Thanks & Regards

Niranjan

0 Likes
Message 6 of 7

tdant
Collaborator
Collaborator

Try this save dialog:

' Save any changes to the SAT file
AsmDoc.Save();
' Save current translated SAT to IAM AsmDoc.SaveAs(AsmDoc.FullFileName.Replace(".sat", ".iam"), true); AsmDoc.Close(true); InvApp.Quit();
0 Likes
Message 7 of 7

YuhanZhang
Autodesk
Autodesk

Can you double check that in the same folder of your .sat, is there an assembly file has the same file name, and check if the assembly file is read-only or not. You can also try below steps to check where the problem is:

 

1. Create a new Inventor project, specify a new folder as its work space and activate it.

2. Copy your SAT file to the work space.

3. Run the VBA sample I sent you with the SAT full filename.

4. Check the saved assembly if it has the changes made in the code.

 

Please let me if this solves the problem.



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.

0 Likes