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
Solved! Go to Solution.
Solved by bradeneuropeArthur. Go to Solution.
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:
Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
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: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 !
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?
Hi,
What is your network drive called?
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
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: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 !
and your project drive:
like c or d
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
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: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 !
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:
Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
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: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 !
All the drives are networked and we don't use a mapped drive letter and use the full syntax (see attached)
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:
Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
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: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 !
Getting there....
Now getting an error (see attached)
Are you using inventor 2015?
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
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: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 !
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:
Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
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: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 !
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.
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:
Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
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: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 !
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:
Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
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: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 !
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
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:
Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
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: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 !
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)
@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
Can't find what you're looking for? Ask the community or share your knowledge.