VBA Code for exporting SAT files - Help needed from someone with VBA knowledge

VBA Code for exporting SAT files - Help needed from someone with VBA knowledge

Anonymous
Not applicable
2,534 Views
24 Replies
Message 1 of 25

VBA Code for exporting SAT files - Help needed from someone with VBA knowledge

Anonymous
Not applicable

Hello,

 

We currently use a simple VBA macro to generate a DXF of a drawing to a specific folder by clicking on a button. We need the same function for creating a SAT file from an IPT (sheet metal part) and I am struggling to make this work. I know it is probably possible with Ilogic but would prefer to just add have this as the same function we have on the DXF.

 

This would export the IPT as a 3D model (not the flat pattern) to a specified folder and keep the original filename but as *.SAT

 

The code we use for the DXF export is below. If any VBA experts out there could help with some code for SAT files it would be appreciated.

 

Thanks

 

Fred

 

Sub EXPORT()

Dim invApp As Inventor.Application
Set invApp = ThisApplication
invApp.SilentOperation = True

Dim idwDoc As Inventor.DrawingDocument
Set idwDoc = invApp.ActiveDocument

Dim dxfFile As String
dxfFile = idwDoc.FullFileName
dxfFile = "\\HKEURVAULT\Inventor Resources\DXF_FOR_LAYOUTS\" & idwDoc.DisplayName

Mid(dxfFile, Len(dxfFile) - 3) = ".dxf"

With invApp.CommandManager
Call .PostPrivateEvent(kFileNameEvent, dxfFile)
Call .StartCommand(kFileSaveCopyAsCommand)
End With

Set idwDoc = Nothing
invApp.SilentOperation = False
Set invApp = Nothing

End Sub

0 Likes
Accepted solutions (1)
2,535 Views
24 Replies
Replies (24)
Message 2 of 25

bradeneuropeArthur
Mentor
Mentor
Module CreateSatFile

    Private m_invApp As Inventor.Application

    Public Sub ExportToSat()

        set m_invApp = thisapplication
        Dim oSATTrans As TranslatorAddIn

        set oSATTrans = m_invApp.ApplicationAddIns.ItemById("{89162634-02B6-11D5-8E80-0010B541CD80}")

        If oSATTrans Is Nothing Then
                        Exit Sub
        End If

        Dim oContext As TranslationContext
        set oContext = m_invApp.TransientObjects.CreateTranslationContext
        Dim oOptions As NameValueMap
        set oOptions = m_invApp.TransientObjects.CreateNameValueMap

        If oSATTrans.HasSaveCopyAsOptions(m_invApp.ActiveDocument, oContext, oOptions) Then

            oOptions.Value("ExportUnits") = 5

            oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism

            Dim oData As DataMedium

            set oData = m_invApp.TransientObjects.CreateDataMedium

            oData.FileName = "C:\test\TEST.sat"

            Call oSATTrans.SaveCopyAs(m_invApp.ActiveDocument, oContext, oOptions, oData)

        End If

    End Sub

End Module

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

Message 3 of 25

Anonymous
Not applicable

Thanks for the code....

 

How do I set a default network folder and keep the same filename so everytime we save a SAT it goes to a network folder as the existing filename but as a SAT file?

 

0 Likes
Message 4 of 25

bradeneuropeArthur
Mentor
Mentor

Hi,

 

What is your network drive called?

 

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 5 of 25

Anonymous
Not applicable

 

 

\\hkeurvault\

0 Likes
Message 6 of 25

bradeneuropeArthur
Mentor
Mentor

and your project drive:

like c or d

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 7 of 25

bradeneuropeArthur
Mentor
Mentor

Than use this:

new programmed for network drive: c:\" >>>> to  >>>>"\\hkeurvault\

    Private m_invApp As Inventor.Application

    Public Sub ExportToSat()

        Set m_invApp = ThisApplication
        Dim oSATTrans As TranslatorAddIn

        Set oSATTrans = m_invApp.ApplicationAddIns.ItemById("{89162634-02B6-11D5-8E80-0010B541CD80}")

        If oSATTrans Is Nothing Then
        Exit Sub
        End If

        Dim oContext As TranslationContext
        Set oContext = m_invApp.TransientObjects.CreateTranslationContext
        Dim oOptions As NameValueMap
        Set oOptions = m_invApp.TransientObjects.CreateNameValueMap

        If oSATTrans.HasSaveCopyAsOptions(m_invApp.ActiveDocument, oContext, oOptions) Then

            oOptions.Value("ExportUnits") = 5

            oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism

            Dim oData As DataMedium

            Set oData = m_invApp.TransientObjects.CreateDataMedium

            'oData.FileName = "C:\test\TEST.sat"
            
            Dim oSatFileName As String
            oSatFileName = Replace(m_invApp.ActiveDocument.FullFileName, ".ipt", ".sat") ' ipt to sat
            oSatFileName = Replace(m_invApp.ActiveDocument.FullFileName, "c:\", "\\hkeurvault\") ' c:\ to \\hkeurvault\
            oData.FileName = oSatFileName

            Call oSATTrans.SaveCopyAs(m_invApp.ActiveDocument, oContext, oOptions, oData)

        End If

Hope this will help you!

 

Regards,

 

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 8 of 25

Anonymous
Not applicable

 

 

All the drives are networked and we don't use a mapped drive letter and use the full syntax (see attached)

 

 

0 Likes
Message 9 of 25

bradeneuropeArthur
Mentor
Mentor

than use the last posted code...

 

Regards,

Autodesk Software: Inventor Professional 2018 | Vault Professional 2018 | Autocad Mechanical 2018
Programming Skills: Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
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 !

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 10 of 25

Anonymous
Not applicable

Getting there....

 

Now getting an error (see attached)

0 Likes
Message 11 of 25

bradeneuropeArthur
Mentor
Mentor

Are you using inventor 2015?

 

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 12 of 25

bradeneuropeArthur
Mentor
Mentor

this will do the trick:

    Public Sub ExportToSat()

        Set m_invApp = ThisApplication
        Dim oSATTrans As TranslatorAddIn

        Set oSATTrans = m_invApp.ApplicationAddIns.ItemById("{89162634-02B6-11D5-8E80-0010B541CD80}")

        If oSATTrans Is Nothing Then
        Exit Sub
        End If

        Dim oContext As TranslationContext
        Set oContext = m_invApp.TransientObjects.CreateTranslationContext
        Dim oOptions As NameValueMap
        Set oOptions = m_invApp.TransientObjects.CreateNameValueMap

        If oSATTrans.HasSaveCopyAsOptions(m_invApp.ActiveDocument, oContext, oOptions) Then

            oOptions.Value("ExportUnits") = 5

            oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism

            Dim oData As DataMedium

            Set oData = m_invApp.TransientObjects.CreateDataMedium

            'oData.FileName = "C:\test\TEST.sat"
            
            Dim oSatFileName As String
            
            oSatFileName = Replace(m_invApp.ActiveDocument.FullFileName, ".ipt", ".sat") ' ipt to sat
            oSatFileName = Replace(m_invApp.ActiveDocument.FullFileName, "C:\", "\\hkeurvault\") ' c:\ to \\hkeurvault\
            MsgBox oSatFileName
            oData.FileName = oSatFileName

            Call oSATTrans.SaveCopyAs(m_invApp.ActiveDocument, oContext, oOptions, oData)

        End If

    End Sub

the drive c: was written to lower and must be upper C:

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 13 of 25

Anonymous
Not applicable

Hi,

 

It is now trying to create an odd folder string but maybe I didn't explain the current structure correctly....

 

We are using Vault and the local path for our files are C:\VAULT\DESIGNS\ and then we separate the folders further by customer and part number etc. The SAT files we need are for our brake press and need to be on the network server in a flat folder structure her \\hkeurvault\SAT_FILES\

 

It seems like the code is creating a mixture of the network path and the local path? I attached a couple of screenshots.

 

 

 

 

0 Likes
Message 14 of 25

bradeneuropeArthur
Mentor
Mentor

So:

The files are located always in for example: C:\VAULT\DESIGNS\Customer001\Brake.ipt

and must be exported always to:  \\hkeurvault\SAT_FILES\Brake.sat

 

Correct?

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 15 of 25

bradeneuropeArthur
Mentor
Mentor

Then this should work:

  Public Sub ExportToSat()

        Set m_invApp = ThisApplication
        Dim oSATTrans As TranslatorAddIn

        Set oSATTrans = m_invApp.ApplicationAddIns.ItemById("{89162634-02B6-11D5-8E80-0010B541CD80}")

        If oSATTrans Is Nothing Then
        Exit Sub
        End If

        Dim oContext As TranslationContext
        Set oContext = m_invApp.TransientObjects.CreateTranslationContext
        Dim oOptions As NameValueMap
        Set oOptions = m_invApp.TransientObjects.CreateNameValueMap

        If oSATTrans.HasSaveCopyAsOptions(m_invApp.ActiveDocument, oContext, oOptions) Then

            oOptions.Value("ExportUnits") = 5

            oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism

            Dim oData As DataMedium

            Set oData = m_invApp.TransientObjects.CreateDataMedium
            
            Dim oSatFileName As String
            
            oSatFileName = Replace(m_invApp.ActiveDocument.FullFileName, ".ipt", ".sat") ' ipt to sat
            On Error Resume Next
    
            MkDir ("\\hkeurvault\SAT_FILES\")
            
            Err.Clear
            
            oData.FileName = "\\hkeurvault\SAT_FILES\" & oSatFileName

            Call oSATTrans.SaveCopyAs(m_invApp.ActiveDocument, oContext, oOptions, oData)

        End If

    End Sub

Regards,

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 16 of 25

Anonymous
Not applicable

HI,

 

Yes that is correct but obviously the IPT folder varies every time depending on which files we are exporting to the network. 

 

Thanks

 

Andy

0 Likes
Message 17 of 25

bradeneuropeArthur
Mentor
Mentor

please give me two examples of the export folder depending of the file exported.

and please give me the feedback I need to have about what is defining the folder names...

see the new code posted too...

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 18 of 25

Anonymous
Not applicable

Hi 

 

Please see screen shots...

 

Capture6 = current error with new code

Capture7 = IPT typical folder

Capture8 = Network folder (SAT file is there from a manual savecopyas test)

0 Likes
Message 19 of 25

Anonymous
Not applicable

Yes still on Inventor 2015 until the end of the year

0 Likes
Message 20 of 25

Anonymous
Not applicable

@bradeneuropeArthur wrote:

please give me two examples of the export folder depending of the file exported.


The export folder will always be the same \\HKEURVAULT\SAT_FILES

All of the exported SAT files should be in the same folder with no additional sub folders

 

Hope it is clear

0 Likes