Hallo!
ich versuche hier seid geraumer Zeit ein Makro auf die Beine zu stellen was folgendes machen soll:
Alle Eigenschaftsfelder mit Inhalt in den benutzerdefinierten übertragen in die konfigurationsspezifischen.
Hier ist der Code, den ich versuche umzumüntzen, aber meine letzten Gehversuche sind schon 10 Jahre her, als ich das letzte Mal ein
Makro umgeschrieben hatte.
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim Part As SldWorks.PartDoc
Dim Doc As SldWorks.ModelDoc2
Dim SelMgr As SldWorks.SelectionMgr
Function BOMPartNumber(config As SldWorks.Configuration, document As SldWorks.ModelDoc2) As String
Select Case config.BOMPartNoSource
Case SwConst.swBOMPartNumberSource_e.swBOMPartNumber_ConfigurationName
BOMPartNumber = config.Name
Case SwConst.swBOMPartNumberSource_e.swBOMPartNumber_DocumentName
BOMPartNumber = document.GetTitle
Case SwConst.swBOMPartNumberSource_e.swBOMPartNumber_UserSpecified
BOMPartNumber = config.AlternateName
Case SwConst.swBOMPartNumberSource_e.swBOMPartNumber_ParentName
Dim parentConfig As SldWorks.Configuration
Set parentConfig = config.GetParent
If parentConfig.BOMPartNoSource = SwConst.swBOMPartNumberSource_e.swBOMPartNumber_ParentName Then
BOMPartNumber = BOMPartNumber(parentConfig, document)
Else
BOMPartNumber = parentConfig.Name
End If
End Select
End Function
Function InspectConfigurations(Doc As SldWorks.ModelDoc2)
Dim params As Variant
params = Doc.GetConfigurationNames
Dim vName As Variant
Dim Name As String
Dim thisConfig As Configuration
For Each vName In params
Name = vName
Set thisConfig = Doc.GetConfigurationByName(Name)
Debug.Print "Name ", thisConfig.Name
' Work out what the BOM part number is based on any derived configurations
Debug.Print "BOMPartNumber ", BOMPartNumber(thisConfig, Doc)
Debug.Print "AlternateName ", thisConfig.AlternateName
Debug.Print "Comment ", thisConfig.Comment
Debug.Print "Description ", thisConfig.Description
Debug.Print "HideNewComponentModels ", thisConfig.HideNewComponentModels
Debug.Print "Lock ", thisConfig.Lock
Debug.Print "ShowChildComponentsInBOM ", thisConfig.ShowChildComponentsInBOM
Debug.Print "UseAlternateNameInBOM ", thisConfig.UseAlternateNameInBOM
Debug.Print "SuppressNewComponentModels", thisConfig.SuppressNewComponentModels
Debug.Print "SuppressNewFeatures ", thisConfig.SuppressNewFeatures
Debug.Print "------------------------------------------------------------------"
Next vName
End Function
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Set Doc = Part
Set SelMgr = Doc.SelectionManager
Call InspectConfigurations(Doc)
Dim params As Variant
params = Doc.GetConfigurationNames
Dim vName As Variant
Dim Name As String
Dim thisConfig As Configuration
Debug.Print "Modifying the configurations..."
For Each vName In params
Name = vName
Set thisConfig = Doc.GetConfigurationByName(Name)
Debug.Print "Name ", thisConfig.Name
thisConfig.BOMPartNoSource = swBOMPartNumber_UserSpecified
thisConfig.AlternateName = "XXXX"
thisConfig.UseAlternateNameInBOM = True
thisConfig.AlternateName = "XXXX"
Next vName
Debug.Print "------------------------------------------------------------------"
Call InspectConfigurations(Doc)
End Sub
Über Ansätze die mich weiterbringen bin ich wie immer dankbar.
Besten Grüße,
CAD-Freelancer
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP