I have a macro that batch process save all configs as .SAT files using config name.
I need to use a coordinate system "Coordinate System1" (its set up to match autocad axis).
The problem is that the coordinate system is only being applied to first config that is saved and all other configs are not using "Coordinate System1".
How do I fix the below code to use "Coordinate System1". for all .SAT files that are exported?
'---------------------------------------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim Model As ModelDoc2
Dim LongStatus As Long
Sub main()
Set swApp = Application.SldWorks
Set Model = swApp.ActiveDoc
Dim ConfigMgr As ConfigurationManager
Dim C1a As Configuration
Dim SelMgr As SelectionMgr
Set SelMgr = Model.SelectionManager
Set ConfigMgr = Model.ConfigurationManager
' Create a new configuration named Config1
' ConfigMgr.AddConfiguration "Config1", "Config1 comment", "alternateName", 1, "", "no description"
' Create a derived configuration called "Config1 Derived" whose parent configuration is "Config1"
' ConfigMgr.AddConfiguration "Config1 Derived", "Config1 Derived Comment", "Alternate Name", 1, "Config1", "no description"
' Show Config1 and make it the active configuration
Model.Extension.SetUserPreferenceString swFileSaveAsCoordinateSystem, 0, "Coordinate System1"
Model.ShowConfiguration2 ("Default")
' Get Config1
Set C1a = Model.GetActiveConfiguration
' Determine if the active configuration is a derived configuration
' Debug.Print C1a.Name & " configuration derived? " & C1a.IsDerived
' Dim VChildren As Variant
' Determine the number of children configurations
' Debug.Print " Number of children configurations: " & C1a.GetChildrenCount
' Get all of the children configurations
' VChildren = C1a.GetChildren
' Dim CDerived As Configuration
' Set CDerived = VChildren(0)
' Determine if the active configuration is a derived configuration
' Debug.Print CDerived.Name & " configuration derived? " & CDerived.IsDerived
' Dim CParent As Configuration
' Get the parent configuration of the derived configuration
' Set CParent = CDerived.GetParent
' Determine the number of configurations in this document
' Debug.Print "Number of configurations in part: " & swApp.GetConfigurationCount("C:\Users\Public\Documents\SOLIDWORKS\SOLIDWORKS 2017\tutorial\api\2012-sm.sldprt")
Dim V As Variant
' Get the names of these configurations
V = swApp.GetConfigurationNames(Model.GetPathName)
Dim i As Long
Debug.Print "Names of configurations in part:"
Dim Folder As String
Folder = InputBox("Please enter the path to the folder where you want to store the .SAT files", ".SAT Configuration Export", "E:\BRC\Library\Casegood\SAT")
For i = 0 To UBound(V)
' Print the names of these configurations
Debug.Print " " & V(i)
Model.ShowConfiguration2 (V(i))
LongStatus = Model.SaveAs3(Folder & "\" & V(i) & ".SAT", 0, 0)
Next
End Sub
SolidworksApi/macros