Ich habe mir ein Code gebastelt, aber das funktioniert noch nicht ganz:
----------------------------------------
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swFeature As SldWorks.Feature
Dim swAssy As SldWorks.AssemblyDoc
Dim boolstatus As Long
Dim KonfName As String
Dim CompName As String
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
'Sicherungsabfragen
If swModel Is Nothing Then
MsgBox "Bitte öffnen Sie ein Dokument.", vbCritical, "Fehler: Kein Dokument geöffnet"
GoTo Abbrechen
End If
If Not swModel.GetType = SwConst.swDocumentTypes_e.swDocASSEMBLY Then
MsgBox "Das geöffnete Dokument ist keine Baugruppe.", vbCritical, "Fehler: Keine Baugruppe geöffnet"
GoTo Abbrechen
End If
'Auf X/Y/Z schalten und Konf. umschalten
swModel.ShowConfiguration2 ("X")
KonfName = "X"
Call KonfUmschalten(swModel, KonfName)
swModel.ShowConfiguration2 ("Y")
KonfName = "Y"
Call KonfUmschalten(swModel, KonfName)
swModel.ShowConfiguration2 ("Z")
KonfName = "Z"
Call KonfUmschalten(swModel, KonfName)
swModel.ShowConfiguration2 ("Standard")
Abbrechen:
Set swModel = Nothing
Set swApp = Nothing
End Sub
Sub KonfUmschalten(swModel As ModelDoc2, KonfName As String)
Dim FeatType As String
'Dim FeatName As String
Set swFeature = swModel.FirstFeature
While Not swFeature Is Nothing
FeatType = swFeature.GetTypeName2
'FeatName = swFeature.Name
If FeatType = "Reference" Then
swFeature.Select2 False, 0
Set swAssy = swFeature
swAssy.CompConfigProperties4 2, 0, True, True, KonfName, False
End If
Set swFeature = swFeature.GetNextFeature
Wend
End Sub
------------------------------
Bei der fett markierten Zeile hakt es.
Gibt es auch eine andere Methode die Konfigurationen umzuschalten außer mit Feature?
Das Problem ist, dass die Komponenten erst "select" werden müssen.
------------------
Gruß Fabi
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP