Hallo zusammen.
Ich habe da mal eine Frage bezüglich eines Makros.
Ich arbeite mit SolidWorks 2010 und möchte Baugruppen, die aus zwei Teilen bestehen, abspeichern. In beiden Teilen ist jeweils eine Konfigurationstabelle hinterlegt.
Es gibt immer nur eine Kombination die zusammengehört. In der Baugruppe habe ich eine weitere Konfigurationstabelle erstellt, in der die passenden Kombinationen aufgelistet sind.
Nun möchte ich die verschiedenen Baugruppen einzeln abspeichern.
Ich habe ein Makro, das bei mir allerdings nicht funktioniert. Kennt sich jemand damit aus oder hat jemand ein ähnliches, funktionierendes Makro?
Gibt es eine Alternative?
'This macro cycles through each configurations of the active part and performs a
'save-as to create a new part for each configuration called conf_name+part_name.sldprt in a folder called 'New Files'
'Delete_non_active_configs_from_all_parts_in_folder.swp can then be used to remove the non-active configs from these parts.
'PRECONDITIONS
'The user must set the paths for filedir and filedir1 as required and make sure the folders exist.
'The files are not read only
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim bool As Boolean
Dim i As Long
Dim filename1 As String
Const filedir As String = "N:\Customer Issues\wk26\Macro\"
Const filedir1 As String = "N:\Customer Issues\wk26\Macro\New_Files\"
Const filemask As String = "*.sldprt"
Dim filename As String
Dim errors As Long
Dim warnings As Long
Dim nRetval As Long
Dim vDepend As Variant
Dim swConfigurationManager As SldWorks.ConfigurationManager
Dim swConfiguration As SldWorks.Configuration
Dim strConfigurationName As String
Dim strActiveConfigurationName As String
Dim ConfigNamesArray As Variant
Dim ConfigName As Variant
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
'Get name of open file
filename = swModel.GetTitle
'Cycle through configs creating a new Part for each.
ConfigNamesArray = swModel.GetConfigurationNames
For i = 0 To UBound(ConfigNamesArray)
ConfigName = ConfigNamesArray(i)
swModel.ShowConfiguration2 ConfigName
'MsgBox " the active configuration is " & ConfigName
filename1 = ConfigName & "_" & filename
bool = swModel.SaveAs4(filedir1 + filename1, swSaveAsVersion_e.swSaveAsCurrentVersion, swSaveAsOptions_e.swSaveAsOptions_Silent, errors, warnings)
Next i
'Close active document.
swApp.QuitDoc (filename1)
End Sub
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP