Ik ben op zoek naar alle eigenschappen, maar sommige eigenschappen in alle PRT-, ASM- en DRW-bestanden @-configuraties.
Ik heb deze code gevonden die alle eigenschappen in de configuraties verwijdert, die ik een beetje heb aangepast.
Hoe sluit ik meerdere woningen uit? De code verwijdert een variabele.
In mijn geval DESIGNATION_FR, DESIGNATION_UK, CODE_ARTICLE en NUM_PLAN
Optie Expliciete Sub hoofd() Dim swApp als SldWorks.SldWorks Dim swModel als SldWorks.ModelDoc2 Dim swConfig als SldWorks.Configuration Dim swCustPropMgr As SldWorks.CustomPropertyManager Dim vPropNames als variant Dim vPropName als variant Dim configNames als variant Dim configName als variant Stel swApp = Toepassing.SldWorks in Stel swModel = swApp.ActiveDoc in
Voor elke configName In configNames Set swConfig = swModel.GetConfigurationByName(configName) Stel swCustPropMgr in = swConfig.CustomPropertyManager vPropNames = swCustPropMgr.GetNames Voor elke vPropName in vPropNames Als vPropName "DESIGNATION_FR" <>, dan swCustPropMgr.Delete vPropName Einde als Volgend
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swConfig As SldWorks.Configuration
Dim swCustPropMgr As SldWorks.CustomPropertyManager
Dim vPropNames As Variant
Dim vPropName As Variant
Dim configNames As Variant
Dim configName As Variant
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
If swModel Is Nothing Then
swApp.SendMsgToUser2 "Ouvrir un fichier pièce", swMbWarning, swMbOk
Exit Sub
End If
If swModel.GetType <> swDocPART Then
swApp.SendMsgToUser2 "Ouvrir un fichier pièce", swMbWarning, swMbOk
Exit Sub
End If
Set swCustPropMgr = swModel.Extension.CustomPropertyManager(Empty)
vPropNames = swCustPropMgr.GetNames
For Each vPropName In vPropNames
If vPropName <> "DESIGNATION_FR" AND vPropName <> "DESIGNATION_UK" AND vPropName <> "CODE_ARTICLE" AND vPropName <> "NUM_PLAN" Then
swCustPropMgr.Delete vPropName
End If
Next
configNames = swModel.GetConfigurationNames
For Each configName In configNames
Set swConfig = swModel.GetConfigurationByName(configName)
Set swCustPropMgr = swConfig.CustomPropertyManager
vPropNames = swCustPropMgr.GetNames
For Each vPropName In vPropNames
If vPropName <> "DESIGNATION_FR" AND vPropName <> "DESIGNATION_UK" AND vPropName <> "CODE_ARTICLE" AND vPropName <> "NUM_PLAN" Then
swCustPropMgr.Delete vPropName
End If
Next
Next
End Sub
Dit komt waarschijnlijk door het feit dat je geen eigenschappen in de betreffende configuratie hebt, je kunt een test doen door te zetten:
If IsEmpty(vPropNames) = False Then
For Each vPropName In vPropNames
If vPropName <> "DESIGNATION_FR" And vPropName <> "DESIGNATION_UK" And vPropName <> "CODE_ARTICLE" And vPropName <> "NUM_PLAN" Then
swCustPropMgr.Delete vPropName
End If
Next
End If